From b394a64ac241fa9a973a6191a70a86b65ab579c2 Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Tue, 19 Apr 2022 16:48:23 -0700 Subject: [PATCH 01/16] remove all deprecations --- discretize/Tests/__init__.py | 6 - discretize/View.py | 9 - discretize/base/base_mesh.py | 55 +---- discretize/base/base_regular_mesh.py | 222 +----------------- discretize/base/base_tensor_mesh.py | 93 +------- discretize/cylindrical_mesh.py | 75 +----- discretize/mixins/mesh_io.py | 40 ---- discretize/mixins/mpl_mod.py | 89 ------- discretize/mixins/vtk_mod.py | 30 --- .../operators/differential_operators.py | 76 ------ discretize/operators/inner_products.py | 114 +-------- discretize/tensor_mesh.py | 15 -- discretize/tests.py | 12 - discretize/tree_mesh.py | 79 +------ discretize/utils/__init__.py | 22 -- discretize/utils/code_utils.py | 7 - discretize/utils/codeutils.py | 8 - discretize/utils/coordinate_utils.py | 10 +- discretize/utils/coordutils.py | 8 - discretize/utils/curvilinear_utils.py | 18 +- discretize/utils/curvutils.py | 8 - discretize/utils/interpolation_utils.py | 6 - discretize/utils/interputils.py | 8 - discretize/utils/matrix_utils.py | 66 +----- discretize/utils/matutils.py | 8 - discretize/utils/mesh_utils.py | 22 +- discretize/utils/meshutils.py | 8 - 27 files changed, 19 insertions(+), 1095 deletions(-) delete mode 100644 discretize/Tests/__init__.py delete mode 100644 discretize/View.py delete mode 100644 discretize/utils/codeutils.py delete mode 100644 discretize/utils/coordutils.py delete mode 100644 discretize/utils/curvutils.py delete mode 100644 discretize/utils/interputils.py delete mode 100644 discretize/utils/matutils.py delete mode 100644 discretize/utils/meshutils.py diff --git a/discretize/Tests/__init__.py b/discretize/Tests/__init__.py deleted file mode 100644 index 5ad47cda6..000000000 --- a/discretize/Tests/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from discretize.tests import * -from discretize.utils.code_utils import deprecate_module - -# note this needs to be a module with an __init__ so we can avoid name clash -# with tests.py in the discretize directory on systems that are agnostic to Case. -deprecate_module("discretize.Tests", "discretize.tests", removal_version="1.0.0", future_warn=False) diff --git a/discretize/View.py b/discretize/View.py deleted file mode 100644 index d312751da..000000000 --- a/discretize/View.py +++ /dev/null @@ -1,9 +0,0 @@ -from discretize.utils.code_utils import deprecate_module - -deprecate_module( - "discretize.View", "discretize.mixins.mpl_mod", removal_version="1.0.0", future_warn=False -) -try: - from discretize.mixins.mpl_mod import Slicer -except ImportError: - pass diff --git a/discretize/base/base_mesh.py b/discretize/base/base_mesh.py index 313ea6489..8888f04e3 100644 --- a/discretize/base/base_mesh.py +++ b/discretize/base/base_mesh.py @@ -1,9 +1,8 @@ import numpy as np -import warnings import os import json from scipy.spatial import KDTree -from discretize.utils.code_utils import deprecate_property, deprecate_method, as_array_n_by_dim +from discretize.utils.code_utils import as_array_n_by_dim class BaseMesh: @@ -141,7 +140,7 @@ def deserialize(cls, items, **kwargs): items.pop("__class__", None) return cls(**items) - def save(self, file_name="mesh.json", verbose=False, **kwargs): + def save(self, file_name="mesh.json", verbose=False): """Save the mesh to json This method is used to save a mesh by writing @@ -155,14 +154,6 @@ def save(self, file_name="mesh.json", verbose=False, **kwargs): verbose : bool, optional If *True*, the path of the json file is printed """ - - if "filename" in kwargs: - file_name = kwargs["filename"] - warnings.warn( - "The filename keyword argument has been deprecated, please use file_name. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) f = os.path.abspath(file_name) # make sure we are working with abs path with open(f, "w") as outfile: json.dump(self.to_dict(), outfile) @@ -3553,45 +3544,3 @@ def _parse_location_type(self, location_type): return "cell_centers" else: return location_type - - # DEPRECATED - normals = deprecate_property("face_normals", "normals", removal_version="1.0.0", future_warn=False) - tangents = deprecate_property("edge_tangents", "tangents", removal_version="1.0.0", future_warn=False) - projectEdgeVector = deprecate_method( - "project_edge_vector", "projectEdgeVector", removal_version="1.0.0", future_warn=False - ) - projectFaceVector = deprecate_method( - "project_face_vector", "projectFaceVector", removal_version="1.0.0", future_warn=False - ) - getInterpolationMat = deprecate_method( - "get_interpolation_matrix", "getInterpolationMat", removal_version="1.0.0", future_warn=False - ) - nodalGrad = deprecate_property( - "nodal_gradient", "nodalGrad", removal_version="1.0.0", future_warn=False - ) - nodalLaplacian = deprecate_property( - "nodal_laplacian", "nodalLaplacian", removal_version="1.0.0", future_warn=False - ) - faceDiv = deprecate_property("face_divergence", "faceDiv", removal_version="1.0.0", future_warn=False) - edgeCurl = deprecate_property("edge_curl", "edgeCurl", removal_version="1.0.0", future_warn=False) - getFaceInnerProduct = deprecate_method( - "get_face_inner_product", "getFaceInnerProduct", removal_version="1.0.0", future_warn=False - ) - getEdgeInnerProduct = deprecate_method( - "get_edge_inner_product", "getEdgeInnerProduct", removal_version="1.0.0", future_warn=False - ) - getFaceInnerProductDeriv = deprecate_method( - "get_face_inner_product_deriv", - "getFaceInnerProductDeriv", - removal_version="1.0.0", - future_warn=False - ) - getEdgeInnerProductDeriv = deprecate_method( - "get_edge_inner_product_deriv", - "getEdgeInnerProductDeriv", - removal_version="1.0.0", - future_warn=False - ) - vol = deprecate_property("cell_volumes", "vol", removal_version="1.0.0", future_warn=False) - area = deprecate_property("face_areas", "area", removal_version="1.0.0", future_warn=False) - edge = deprecate_property("edge_lengths", "edge", removal_version="1.0.0", future_warn=False) diff --git a/discretize/base/base_regular_mesh.py b/discretize/base/base_regular_mesh.py index 6030cf08e..d9b8d53dd 100644 --- a/discretize/base/base_regular_mesh.py +++ b/discretize/base/base_regular_mesh.py @@ -5,8 +5,6 @@ import numpy as np from discretize.utils import mkvc, Identity from discretize.base.base_mesh import BaseMesh -from discretize.utils.code_utils import deprecate_method -import warnings class BaseRegularMesh(BaseMesh): @@ -506,80 +504,6 @@ def rotation_matrix(self): """ return self.orientation # np.array([self.axis_u, self.axis_v, self.axis_w]) - @property - def axis_u(self): - """ - .. deprecated:: 0.7.0 - `axis_u` will be removed in discretize 1.0.0. This functionality was replaced - by the :py:attr:`~.BaseRegularMesh.orientation`. - """ - warnings.warn( - "The axis_u property is deprecated, please access as self.orientation[0]. " - "This will be removed in discretize 1.0.0.", - DeprecationWarning, - ) - return self.orientation[0] - - @axis_u.setter - def axis_u(self, value): - warnings.warn( - "Setting the axis_u property is deprecated, and now unchecked, please " - "directly set the self.orientation property. This will be removed in " - "discretize 1.0.0.", - DeprecationWarning, - ) - self.orientation[0] = value - - @property - def axis_v(self): - """ - .. deprecated:: 0.7.0 - `axis_v` will be removed in discretize 1.0.0. This functionality was replaced - by the :py:attr:`~.BaseRegularMesh.orientation`. - """ - warnings.warn( - "The axis_v property is deprecated, please access as self.orientation[1]. " - "This will be removed in discretize 1.0.0.", - DeprecationWarning, - ) - return self.orientation[1] - - @axis_v.setter - def axis_v(self, value): - warnings.warn( - "Setting the axis_v property is deprecated, and now unchecked, please " - "directly set the self.orientation property. This will be removed in " - "discretize 1.0.0.", - DeprecationWarning, - ) - value = value / np.linalg.norm(value) - self.orientation[1] = value - - @property - def axis_w(self): - """ - .. deprecated:: 0.7.0 - `axis_w` will be removed in discretize 1.0.0. This functionality was replaced - by the :py:attr:`~.BaseRegularMesh.orientation`. - """ - warnings.warn( - "The axis_w property is deprecated, please access as self.orientation[2]. " - "This will be removed in discretize 1.0.0.", - DeprecationWarning, - ) - return self.orientation[2] - - @axis_w.setter - def axis_w(self, value): - warnings.warn( - "Setting the axis_v property is deprecated, and now unchecked, please " - "directly set the self.orientation property. This will be removed in " - "discretize 1.0.0.", - DeprecationWarning, - ) - value = value / np.linalg.norm(value) - self.orientation[2] = value - class BaseRectangularMesh(BaseRegularMesh): """ @@ -812,7 +736,7 @@ def n_faces_z(self): return int(np.prod(self.shape_faces_z)) def reshape( - self, x, x_type="cell_centers", out_type="cell_centers", format="V", **kwargs + self, x, x_type="cell_centers", out_type="cell_centers", format="V", ): """General reshape method for tensor quantities @@ -841,21 +765,6 @@ def reshape( - *M:* return matrix (nD array) or a list of matrices """ - if "xType" in kwargs: - warnings.warn( - "The xType keyword argument has been deprecated, please use x_type. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - x_type = kwargs["xType"] - if "outType" in kwargs: - warnings.warn( - "The outType keyword argument has been deprecated, please use out_type. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - out_type = kwargs["outType"] - x_type = self._parse_location_type(x_type) out_type = self._parse_location_type(out_type) @@ -987,132 +896,3 @@ def switchKernal(xx): return out else: return switchKernal(x) - - # DEPRECATED - r = deprecate_method("reshape", "r", removal_version="1.0.0") - - @property - def nCx(self): - """Number of cells in the x direction - - Returns - ------- - int - - .. deprecated:: 0.5.0 - `nCx` will be removed in discretize 1.0.0, it is replaced by - `mesh.shape_cells[0]` to reduce namespace clutter. - """ - - warnings.warn( - "nCx has been deprecated, please access as mesh.shape_cells[0]", - DeprecationWarning, - ) - return self.shape_cells[0] - - @property - def nCy(self): - """Number of cells in the y direction - - Returns - ------- - int or None - None if dim < 2 - - .. deprecated:: 0.5.0 - `nCy` will be removed in discretize 1.0.0, it is replaced by - `mesh.shape_cells[1]` to reduce namespace clutter. - """ - - warnings.warn( - "nCy has been deprecated, please access as mesh.shape_cells[1]", - DeprecationWarning, - ) - if self.dim < 2: - return None - return self.shape_cells[1] - - @property - def nCz(self): - """Number of cells in the z direction - - Returns - ------- - int or None - None if dim < 3 - - .. deprecated:: 0.5.0 - `nCz` will be removed in discretize 1.0.0, it is replaced by - `mesh.shape_cells[2]` to reduce namespace clutter. - """ - - warnings.warn( - "nCz has been deprecated, please access as mesh.shape_cells[2]", - DeprecationWarning, - ) - if self.dim < 3: - return None - return self.shape_cells[2] - - @property - def nNx(self): - """Number of nodes in the x-direction - - Returns - ------- - int - - .. deprecated:: 0.5.0 - `nNx` will be removed in discretize 1.0.0, it is replaced by - `mesh.shape_nodes[0]` to reduce namespace clutter. - """ - - warnings.warn( - "nNx has been deprecated, please access as mesh.shape_nodes[0]", - DeprecationWarning, - ) - return self.shape_nodes[0] - - @property - def nNy(self): - """Number of nodes in the y-direction - - Returns - ------- - int or None - None if dim < 2 - - .. deprecated:: 0.5.0 - `nNy` will be removed in discretize 1.0.0, it is replaced by - `mesh.shape_nodes[1]` to reduce namespace clutter. - """ - - warnings.warn( - "nNy has been deprecated, please access as mesh.shape_nodes[1]", - DeprecationWarning, - ) - if self.dim < 2: - return None - return self.shape_nodes[1] - - @property - def nNz(self): - """Number of nodes in the z-direction - - Returns - ------- - int or None - None if dim < 3 - - .. deprecated:: 0.5.0 - `nNz` will be removed in discretize 1.0.0, it is replaced by - `mesh.shape_nodes[2]` to reduce namespace clutter. - """ - - warnings.warn( - "nNz has been deprecated, please access as mesh.shape_nodes[2]", - DeprecationWarning, - ) - if self.dim < 3: - return None - return self.shape_nodes[2] diff --git a/discretize/base/base_tensor_mesh.py b/discretize/base/base_tensor_mesh.py index 2f6a50ffa..0787ee292 100644 --- a/discretize/base/base_tensor_mesh.py +++ b/discretize/base/base_tensor_mesh.py @@ -19,7 +19,6 @@ interpolation_matrix, make_boundary_bool, ) -from discretize.utils.code_utils import deprecate_method, deprecate_property import warnings @@ -631,7 +630,7 @@ def get_tensor(self, key): # --------------- Methods --------------------- - def is_inside(self, pts, location_type="nodes", **kwargs): + def is_inside(self, pts, location_type="nodes"): """Determine which points lie within the mesh For an arbitrary set of points, **is_indside** returns a @@ -652,13 +651,6 @@ def is_inside(self, pts, location_type="nodes", **kwargs): Boolean array identifying points which lie within the mesh """ - if "locType" in kwargs: - warnings.warn( - "The locType keyword argument has been deprecated, please use location_type. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - location_type = kwargs["locType"] pts = as_array_n_by_dim(pts, self.dim) tensors = self.get_tensor(location_type) @@ -772,22 +764,8 @@ def _getInterpolationMat( return Q.tocsr() def get_interpolation_matrix( - self, loc, location_type="cell_centers", zeros_outside=False, **kwargs + self, loc, location_type="cell_centers", zeros_outside=False, ): - if "locType" in kwargs: - warnings.warn( - "The locType keyword argument has been deprecated, please use location_type. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - location_type = kwargs["locType"] - if "zerosOutside" in kwargs: - warnings.warn( - "The zerosOutside keyword argument has been deprecated, please use zeros_outside. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - zeros_outside = kwargs["zerosOutside"] return self._getInterpolationMat(loc, location_type, zeros_outside) def _fastInnerProduct( @@ -1002,70 +980,3 @@ def innerProductDeriv(v=None): return innerProductDeriv else: return None - - # DEPRECATED - @property - def hx(self): - """Width of cells in the x direction - - Returns - ------- - numpy.ndarray - - .. deprecated:: 0.5.0 - `hx` will be removed in discretize 1.0.0 to reduce namespace clutter, - please use `mesh.h[0]`. - """ - warnings.warn( - "hx has been deprecated, please access as mesh.h[0]", DeprecationWarning - ) - return self.h[0] - - @property - def hy(self): - """Width of cells in the y direction - - Returns - ------- - numpy.ndarray or None - - .. deprecated:: 0.5.0 - `hy` will be removed in discretize 1.0.0 to reduce namespace clutter, - please use `mesh.h[1]`. - """ - warnings.warn( - "hy has been deprecated, please access as mesh.h[1]", DeprecationWarning - ) - return None if self.dim < 2 else self.h[1] - - @property - def hz(self): - """Width of cells in the z direction - - Returns - ------- - numpy.ndarray or None - - .. deprecated:: 0.5.0 - `hz` will be removed in discretize 1.0.0 to reduce namespace clutter, - please use `mesh.h[2]`. - """ - warnings.warn( - "hz has been deprecated, please access as mesh.h[2]", DeprecationWarning - ) - return None if self.dim < 3 else self.h[2] - - vectorNx = deprecate_property("nodes_x", "vectorNx", removal_version="1.0.0", future_warn=False) - vectorNy = deprecate_property("nodes_y", "vectorNy", removal_version="1.0.0", future_warn=False) - vectorNz = deprecate_property("nodes_z", "vectorNz", removal_version="1.0.0", future_warn=False) - vectorCCx = deprecate_property( - "cell_centers_x", "vectorCCx", removal_version="1.0.0", future_warn=False - ) - vectorCCy = deprecate_property( - "cell_centers_y", "vectorCCy", removal_version="1.0.0", future_warn=False - ) - vectorCCz = deprecate_property( - "cell_centers_z", "vectorCCz", removal_version="1.0.0", future_warn=False - ) - isInside = deprecate_method("is_inside", "isInside", removal_version="1.0.0", future_warn=False) - getTensor = deprecate_method("get_tensor", "getTensor", removal_version="1.0.0", future_warn=False) diff --git a/discretize/cylindrical_mesh.py b/discretize/cylindrical_mesh.py index 060e102c1..dae426d62 100644 --- a/discretize/cylindrical_mesh.py +++ b/discretize/cylindrical_mesh.py @@ -16,11 +16,6 @@ from discretize.base import BaseTensorMesh, BaseRectangularMesh from discretize.operators import DiffOperators, InnerProducts from discretize.mixins import InterfaceMixins -from discretize.utils.code_utils import ( - deprecate_class, - deprecate_property, - deprecate_method, -) import warnings @@ -1631,7 +1626,7 @@ def _deflation_matrix(self, location, as_ones=False): #################################################### def get_interpolation_matrix( - self, loc, location_type="cell_centers", zeros_outside=False, **kwargs + self, loc, location_type="cell_centers", zeros_outside=False, ): """Construct interpolation matrix from mesh @@ -1671,20 +1666,6 @@ def get_interpolation_matrix( The interpolation matrix """ - if "locType" in kwargs: - warnings.warn( - "The locType keyword argument has been deprecated, please use location_type. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - location_type = kwargs["locType"] - if "zerosOutside" in kwargs: - warnings.warn( - "The zerosOutside keyword argument has been deprecated, please use zeros_outside. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - zeros_outside = kwargs["zerosOutside"] location_type = self._parse_location_type(location_type) @@ -1713,7 +1694,7 @@ def get_interpolation_matrix( return self._getInterpolationMat(loc, location_type, zeros_outside) - def cartesian_grid(self, location_type="cell_centers", theta_shift=None, **kwargs): + def cartesian_grid(self, location_type="cell_centers", theta_shift=None): """ Takes a grid location ('CC', 'N', 'Ex', 'Ey', 'Ez', 'Fx', 'Fy', 'Fz') and returns that grid in cartesian coordinates @@ -1730,13 +1711,6 @@ def cartesian_grid(self, location_type="cell_centers", theta_shift=None, **kwarg (n_items, dim) numpy.ndarray cartesian coordinates for the cylindrical grid """ - if "locType" in kwargs: - warnings.warn( - "The locType keyword argument has been deprecated, please use location_type. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - location_type = kwargs["locType"] try: grid = getattr(self, location_type).copy() except AttributeError: @@ -1746,7 +1720,7 @@ def cartesian_grid(self, location_type="cell_centers", theta_shift=None, **kwarg return cyl2cart(grid) # TODO: account for cartesian origin def get_interpolation_matrix_cartesian_mesh( - self, Mrect, location_type="cell_centers", location_type_to=None, **kwargs + self, Mrect, location_type="cell_centers", location_type_to=None, ): """Construct projection matrix from ``CylindricalMesh`` to other mesh. @@ -1774,21 +1748,6 @@ def get_interpolation_matrix_cartesian_mesh( interpolation matrix from gridded locations on cylindrical mesh to gridded locations on another mesh """ - if "locType" in kwargs: - warnings.warn( - "The locType keyword argument has been deprecated, please use location_type. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - location_type = kwargs["locType"] - if "locTypeTo" in kwargs: - warnings.warn( - "The locTypeTo keyword argument has been deprecated, please use location_type_to. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - location_type_to = kwargs["locTypeTo"] - location_type = self._parse_location_type(location_type) if not self.is_symmetric: @@ -1867,31 +1826,3 @@ def get_interpolation_matrix_cartesian_mesh( Pc2r = self.get_interpolation_matrix(G, interp_type) Proj = sdiag(proj) return Proj * Pc2r - - # DEPRECATIONS - areaFx = deprecate_property("face_x_areas", "areaFx", removal_version="1.0.0", future_warn=False) - areaFy = deprecate_property("face_y_areas", "areaFy", removal_version="1.0.0", future_warn=False) - areaFz = deprecate_property("face_z_areas", "areaFz", removal_version="1.0.0", future_warn=False) - edgeEx = deprecate_property("edge_x_lengths", "edgeEx", removal_version="1.0.0", future_warn=False) - edgeEy = deprecate_property("edge_y_lengths", "edgeEy", removal_version="1.0.0", future_warn=False) - edgeEz = deprecate_property("edge_z_lengths", "edgeEz", removal_version="1.0.0", future_warn=False) - isSymmetric = deprecate_property( - "is_symmetric", "isSymmetric", removal_version="1.0.0", future_warn=False - ) - cartesianOrigin = deprecate_property( - "cartesian_origin", "cartesianOrigin", removal_version="1.0.0", future_warn=False - ) - getInterpolationMatCartMesh = deprecate_method( - "get_interpolation_matrix_cartesian_mesh", - "getInterpolationMatCartMesh", - removal_version="1.0.0", - future_warn=False - ) - cartesianGrid = deprecate_method( - "cartesian_grid", "cartesianGrid", removal_version="1.0.0", future_warn=False - ) - - -@deprecate_class(removal_version="1.0.0", future_warn=False) -class CylMesh(CylindricalMesh): - pass diff --git a/discretize/mixins/mesh_io.py b/discretize/mixins/mesh_io.py index 7a064311c..f17e38b01 100644 --- a/discretize/mixins/mesh_io.py +++ b/discretize/mixins/mesh_io.py @@ -2,8 +2,6 @@ import numpy as np from discretize.utils import mkvc -from discretize.utils.code_utils import deprecate_method -import warnings try: from discretize.mixins.vtk_mod import InterfaceTensorread_vtk, InterfaceSimplexReadVTK @@ -402,25 +400,6 @@ def write_UBC(mesh, file_name, models=None, directory="", comment_lines=""): ) mesh.write_model_UBC(key, models[key], directory=directory) - # DEPRECATED - @classmethod - def readUBC(TensorMesh, file_name, directory=""): - """*readUBC* has been deprecated and replaced by *read_UBC*""" - warnings.warn( - "TensorMesh.readUBC has been deprecated and will be removed in" - "discretize 1.0.0. please use TensorMesh.read_UBC", - DeprecationWarning, - ) - return TensorMesh.read_UBC(file_name, directory) - - readModelUBC = deprecate_method( - "read_model_UBC", "readModelUBC", removal_version="1.0.0", future_warn=False - ) - writeUBC = deprecate_method("write_UBC", "writeUBC", removal_version="1.0.0", future_warn=False) - writeModelUBC = deprecate_method( - "write_model_UBC", "writeModelUBC", removal_version="1.0.0", future_warn=False - ) - class TreeMeshIO(object): """Class for managing the input/output of tree meshes and models. @@ -587,25 +566,6 @@ def write_model_UBC(mesh, file_name, model, directory=""): m = model[ubc_order] np.savetxt(fname, m) - # DEPRECATED - @classmethod - def readUBC(TreeMesh, file_name, directory=""): - """*readUBC* has been deprecated and replaced by *read_UBC*""" - warnings.warn( - "TensorMesh.readUBC has been deprecated and will be removed in" - "discretize 1.0.0. please use TensorMesh.read_UBC", - DeprecationWarning, - ) - return TreeMesh.read_UBC(file_name, directory) - - readModelUBC = deprecate_method( - "read_model_UBC", "readModelUBC", removal_version="1.0.0", future_warn=False - ) - writeUBC = deprecate_method("write_UBC", "writeUBC", removal_version="1.0.0", future_warn=False) - writeModelUBC = deprecate_method( - "write_model_UBC", "writeModelUBC", removal_version="1.0.0", future_warn=False - ) - class SimplexMeshIO(InterfaceSimplexReadVTK): pass diff --git a/discretize/mixins/mpl_mod.py b/discretize/mixins/mpl_mod.py index 041a49b21..4011a3def 100644 --- a/discretize/mixins/mpl_mod.py +++ b/discretize/mixins/mpl_mod.py @@ -1,7 +1,6 @@ import numpy as np import warnings from discretize.utils import mkvc, ndgrid -from discretize.utils.code_utils import deprecate_method import matplotlib import matplotlib.pyplot as plt @@ -152,12 +151,6 @@ def plot_grid( ) ) - if "showIt" in kwargs: - show_it = kwargs.pop("showIt") - warnings.warn( - "showIt has been deprecated, please use show_it", DeprecationWarning - ) - if ax is not None: ax_test = ax if not isinstance(ax, (list, tuple, np.ndarray)): @@ -289,34 +282,6 @@ def plot_image( ) ) - if "pcolorOpts" in kwargs: - pcolor_opts = kwargs.pop("pcolorOpts") - warnings.warn( - "pcolorOpts has been deprecated, please use pcolor_opts", - DeprecationWarning, - ) - if "streamOpts" in kwargs: - stream_opts = kwargs.pop("streamOpts") - warnings.warn( - "streamOpts has been deprecated, please use stream_opts", - DeprecationWarning, - ) - if "gridOpts" in kwargs: - grid_opts = kwargs.pop("gridOpts") - warnings.warn( - "gridOpts has been deprecated, please use grid_opts", DeprecationWarning - ) - if "showIt" in kwargs: - show_it = kwargs.pop("showIt") - warnings.warn( - "showIt has been deprecated, please use show_it", DeprecationWarning - ) - if "vType" in kwargs: - v_type = kwargs.pop("vType") - warnings.warn( - "vType has been deprecated, please use v_type", DeprecationWarning - ) - # Some Error checking and common defaults if pcolor_opts is None: pcolor_opts = {} @@ -524,33 +489,6 @@ def plot_slice( ) normal = normal.upper() - if "pcolorOpts" in kwargs: - pcolor_opts = kwargs["pcolorOpts"] - warnings.warn( - "pcolorOpts has been deprecated, please use pcolor_opts", - DeprecationWarning, - ) - if "streamOpts" in kwargs: - stream_opts = kwargs["streamOpts"] - warnings.warn( - "streamOpts has been deprecated, please use stream_opts", - DeprecationWarning, - ) - if "gridOpts" in kwargs: - grid_opts = kwargs["gridOpts"] - warnings.warn( - "gridOpts has been deprecated, please use grid_opts", DeprecationWarning - ) - if "showIt" in kwargs: - show_it = kwargs["showIt"] - warnings.warn( - "showIt has been deprecated, please use show_it", DeprecationWarning - ) - if "vType" in kwargs: - v_type = kwargs["vType"] - warnings.warn( - "vType has been deprecated, please use v_type", DeprecationWarning - ) if pcolor_opts is None: pcolor_opts = {} if stream_opts is None: @@ -728,13 +666,6 @@ def plot_3d_slicer( else: fig.clf() - if "pcolorOpts" in kwargs: - pcolor_opts = kwargs["pcolorOpts"] - warnings.warn( - "pcolorOpts has been deprecated, please use pcolor_opts", - DeprecationWarning, - ) - # Populate figure tracker = Slicer( self, @@ -1007,13 +938,6 @@ def __plot_image_tensor( **kwargs, ): - if "annotationColor" in kwargs: - annotation_color = kwargs.pop("annotationColor") - warnings.warn( - "annotationColor has been deprecated, please use annotation_color", - DeprecationWarning, - ) - if self.dim == 1: if v_type == "CC": ph = ax.plot( @@ -2302,10 +2226,6 @@ def __plot_image_simp( return out - plotGrid = deprecate_method("plot_grid", "plotGrid", removal_version="1.0.0", future_warn=False) - plotImage = deprecate_method("plot_image", "plotImage", removal_version="1.0.0", future_warn=False) - plotSlice = deprecate_method("plot_slice", "plotSlice", removal_version="1.0.0", future_warn=False) - class Slicer(object): """Plot slices of a 3D volume, interactively (scroll wheel). @@ -2393,18 +2313,9 @@ def __init__( aspect="auto", grid=[2, 2, 1], pcolor_opts=None, - **kwargs, ): """Initialize interactive figure.""" - # 0. Some checks, not very extensive - if "pcolorOpts" in kwargs: - pcolor_opts = kwargs["pcolorOpts"] - warnings.warn( - "pcolorOpts has been deprecated, please use pcolor_opts", - DeprecationWarning, - ) - # Add pcolor_opts to self self.pc_props = pcolor_opts if pcolor_opts is not None else {} diff --git a/discretize/mixins/vtk_mod.py b/discretize/mixins/vtk_mod.py index eadf23f0f..4b9f98790 100644 --- a/discretize/mixins/vtk_mod.py +++ b/discretize/mixins/vtk_mod.py @@ -441,14 +441,6 @@ def to_vtk(mesh, models=None): ) return cvtd - def toVTK(mesh, models=None): - """*toVTK* has been deprecated and replaced by *to_vtk*""" - warnings.warn( - "Deprecation Warning: `toVTK` is deprecated, use `to_vtk` instead", - category=DeprecationWarning, - ) - return InterfaceVTK.to_vtk(mesh, models=models) - @staticmethod def _save_unstructured_grid(file_name, vtkUnstructGrid, directory=""): """Saves a VTK unstructured grid file (vtu) for an already generated @@ -586,17 +578,6 @@ def write_vtk(mesh, file_name, models=None, directory=""): raise RuntimeError("VTK data type `%s` is not currently supported." % key) return write(file_name, vtkObj, directory=directory) - def writeVTK(mesh, file_name, models=None, directory=""): - """*writeVTK* has been deprecated and replaced by *write_vtk*""" - warnings.warn( - "Deprecation Warning: `writeVTK` is deprecated, use `write_vtk` instead", - category=DeprecationWarning, - ) - return InterfaceVTK.write_vtk( - mesh, file_name, models=models, directory=directory - ) - - class InterfaceTensorread_vtk(object): """ This class provides convenient methods for converting VTK Rectilinear Grid @@ -685,17 +666,6 @@ def read_vtk(TensorMesh, file_name, directory=""): vtrGrid = vtrReader.GetOutput() return TensorMesh.vtk_to_tensor_mesh(vtrGrid) - @classmethod - def readVTK(TensorMesh, file_name, directory=""): - """*readVTK* has been deprecated and replaced by *read_vtk*""" - warnings.warn( - "Deprecation Warning: `readVTK` is deprecated, use `read_vtk` instead", - category=DeprecationWarning, - ) - return InterfaceTensorread_vtk.read_vtk( - TensorMesh, file_name, directory=directory - ) - class InterfaceSimplexReadVTK: diff --git a/discretize/operators/differential_operators.py b/discretize/operators/differential_operators.py index a69e35f3c..694bbe5e6 100644 --- a/discretize/operators/differential_operators.py +++ b/discretize/operators/differential_operators.py @@ -11,7 +11,6 @@ av_extrap, make_boundary_bool, ) -from discretize.utils.code_utils import deprecate_method, deprecate_property def _validate_BC(bc): @@ -1786,35 +1785,6 @@ def cell_gradient_weak_form_robin(self, alpha=0.0, beta=1.0, gamma=0.0): return A, b - @property - def cell_gradient_BC(self): - """ - Boundary conditions matrix for the cell gradient operator (Deprecated) - """ - - warnings.warn("cell_gradient_BC is deprecated and is not longer used. See cell_gradient") - - if getattr(self, "_cell_gradient_BC", None) is None: - BC = self.set_cell_gradient_BC(self._cell_gradient_BC_list) - n = self.vnC - if self.dim == 1: - G = _ddxCellGradBC(n[0], BC[0]) - elif self.dim == 2: - G1 = sp.kron(speye(n[1]), _ddxCellGradBC(n[0], BC[0])) - G2 = sp.kron(_ddxCellGradBC(n[1], BC[1]), speye(n[0])) - G = sp.block_diag((G1, G2), format="csr") - elif self.dim == 3: - G1 = kron3(speye(n[2]), speye(n[1]), _ddxCellGradBC(n[0], BC[0])) - G2 = kron3(speye(n[2]), _ddxCellGradBC(n[1], BC[1]), speye(n[0])) - G3 = kron3(_ddxCellGradBC(n[2], BC[2]), speye(n[1]), speye(n[0])) - G = sp.block_diag((G1, G2, G3), format="csr") - # Compute areas of cell faces & volumes - S = self.face_areas - V = ( - self.aveCC2F * self.cell_volumes - ) # Average volume between adjacent cells - self._cell_gradient_BC = sdiag(S / V) * G - return self._cell_gradient_BC @property def cell_gradient_x(self): @@ -3526,49 +3496,3 @@ def project_node_to_boundary_node(self): is_b = make_boundary_bool(self.shape_nodes) return sp.eye(self.n_nodes, format="csr")[is_b] - - # DEPRECATED - cellGrad = deprecate_property("cell_gradient", "cellGrad", removal_version="1.0.0", future_warn=False) - cellGradBC = deprecate_property( - "cell_gradient_BC", "cellGradBC", removal_version="1.0.0", future_warn=False - ) - cellGradx = deprecate_property( - "cell_gradient_x", "cellGradx", removal_version="1.0.0", future_warn=False - ) - cellGrady = deprecate_property( - "cell_gradient_y", "cellGrady", removal_version="1.0.0", future_warn=False - ) - cellGradz = deprecate_property( - "cell_gradient_z", "cellGradz", removal_version="1.0.0", future_warn=False - ) - faceDivx = deprecate_property( - "face_x_divergence", "faceDivx", removal_version="1.0.0", future_warn=False - ) - faceDivy = deprecate_property( - "face_y_divergence", "faceDivy", removal_version="1.0.0", future_warn=False - ) - faceDivz = deprecate_property( - "face_z_divergence", "faceDivz", removal_version="1.0.0", future_warn=False - ) - _cellGradStencil = deprecate_property( - "stencil_cell_gradient", "_cellGradStencil", removal_version="1.0.0", future_warn=False - ) - _cellGradxStencil = deprecate_property( - "stencil_cell_gradient_x", "_cellGradxStencil", removal_version="1.0.0", future_warn=False - ) - _cellGradyStencil = deprecate_property( - "stencil_cell_gradient_y", "_cellGradyStencil", removal_version="1.0.0", future_warn=False - ) - _cellGradzStencil = deprecate_property( - "stencil_cell_gradient_z", "_cellGradzStencil", removal_version="1.0.0", future_warn=False - ) - - setCellGradBC = deprecate_method( - "set_cell_gradient_BC", "setCellGradBC", removal_version="1.0.0", future_warn=False - ) - getBCProjWF = deprecate_method( - "get_BC_projections", "getBCProjWF", removal_version="1.0.0", future_warn=False - ) - getBCProjWF_simple = deprecate_method( - "get_BC_projections_simple", "getBCProjWF_simple", removal_version="1.0.0", future_warn=False - ) diff --git a/discretize/operators/inner_products.py b/discretize/operators/inner_products.py index a91c5a231..b3ca4fa4b 100644 --- a/discretize/operators/inner_products.py +++ b/discretize/operators/inner_products.py @@ -13,7 +13,6 @@ sdinv, ) import numpy as np -from discretize.utils.code_utils import deprecate_method import warnings @@ -35,30 +34,7 @@ def get_face_inner_product( invert_model=False, invert_matrix=False, do_fast=True, - **kwargs ): - if "invProp" in kwargs: - warnings.warn( - "The invProp keyword argument has been deprecated, please use invert_model. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - invert_model = kwargs["invProp"] - if "invMat" in kwargs: - warnings.warn( - "The invMat keyword argument has been deprecated, please use invert_matrix. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - invert_matrix = kwargs["invMat"] - if "doFast" in kwargs: - warnings.warn( - "The doFast keyword argument has been deprecated, please use do_fast. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - do_fast = kwargs["doFast"] - return self._getInnerProduct( "F", model=model, @@ -73,29 +49,7 @@ def get_edge_inner_product( invert_model=False, invert_matrix=False, do_fast=True, - **kwargs ): - if "invProp" in kwargs: - warnings.warn( - "The invProp keyword argument has been deprecated, please use invert_model. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - invert_model = kwargs["invProp"] - if "invMat" in kwargs: - warnings.warn( - "The invMat keyword argument has been deprecated, please use invert_matrix. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - invert_matrix = kwargs["invMat"] - if "doFast" in kwargs: - warnings.warn( - "The doFast keyword argument has been deprecated, please use do_fast. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - do_fast = kwargs["doFast"] return self._getInnerProduct( "E", model=model, @@ -111,7 +65,6 @@ def _getInnerProduct( invert_model=False, invert_matrix=False, do_fast=True, - **kwargs ): """get the inner product matrix @@ -141,27 +94,6 @@ def _getInnerProduct( M, the inner product matrix (nE, nE) """ - if "invProp" in kwargs: - warnings.warn( - "The invProp keyword argument has been deprecated, please use invert_model. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - invert_model = kwargs["invProp"] - if "invMat" in kwargs: - warnings.warn( - "The invMat keyword argument has been deprecated, please use invert_matrix. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - invert_matrix = kwargs["invMat"] - if "doFast" in kwargs: - warnings.warn( - "The doFast keyword argument has been deprecated, please use do_fast. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - do_fast = kwargs["doFast"] if projection_type not in ["F", "E"]: raise TypeError("projection_type must be 'F' for faces or 'E' for edges") @@ -242,29 +174,8 @@ def _getInnerProductProjectionMatrices(self, projection_type, tensorType): return [V * proj(*locs[node][d - 1]) for node in nodes] def get_face_inner_product_deriv( - self, model, do_fast=True, invert_model=False, invert_matrix=False, **kwargs + self, model, do_fast=True, invert_model=False, invert_matrix=False, ): - if "invProp" in kwargs: - warnings.warn( - "The invProp keyword argument has been deprecated, please use invert_model. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - invert_model = kwargs["invProp"] - if "invMat" in kwargs: - warnings.warn( - "The invMat keyword argument has been deprecated, please use invert_matrix. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - invert_matrix = kwargs["invMat"] - if "doFast" in kwargs: - warnings.warn( - "The doFast keyword argument has been deprecated, please use do_fast. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - do_fast = kwargs["doFast"] return self._getInnerProductDeriv( model, "F", @@ -274,29 +185,8 @@ def get_face_inner_product_deriv( ) def get_edge_inner_product_deriv( - self, model, do_fast=True, invert_model=False, invert_matrix=False, **kwargs + self, model, do_fast=True, invert_model=False, invert_matrix=False, ): - if "invProp" in kwargs: - warnings.warn( - "The invProp keyword argument has been deprecated, please use invert_model. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - invert_model = kwargs["invProp"] - if "invMat" in kwargs: - warnings.warn( - "The invMat keyword argument has been deprecated, please use invert_matrix. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - invert_matrix = kwargs["invMat"] - if "doFast" in kwargs: - warnings.warn( - "The doFast keyword argument has been deprecated, please use do_fast. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - do_fast = kwargs["doFast"] return self._getInnerProductDeriv( model, "E", diff --git a/discretize/tensor_mesh.py b/discretize/tensor_mesh.py index 403bbcd7a..fde7a9412 100644 --- a/discretize/tensor_mesh.py +++ b/discretize/tensor_mesh.py @@ -5,7 +5,6 @@ from discretize.operators import DiffOperators, InnerProducts from discretize.mixins import InterfaceMixins, TensorMeshIO from discretize.utils import mkvc -from discretize.utils.code_utils import deprecate_property class TensorMesh( @@ -566,17 +565,3 @@ def _repr_attributes(self): attrs[name]["nC"] = self.shape_cells[i] return attrs - - # DEPRECATIONS - areaFx = deprecate_property("face_x_areas", "areaFx", removal_version="1.0.0", future_warn=False) - areaFy = deprecate_property("face_y_areas", "areaFy", removal_version="1.0.0", future_warn=False) - areaFz = deprecate_property("face_z_areas", "areaFz", removal_version="1.0.0", future_warn=False) - edgeEx = deprecate_property("edge_x_lengths", "edgeEx", removal_version="1.0.0", future_warn=False) - edgeEy = deprecate_property("edge_y_lengths", "edgeEy", removal_version="1.0.0", future_warn=False) - edgeEz = deprecate_property("edge_z_lengths", "edgeEz", removal_version="1.0.0", future_warn=False) - faceBoundaryInd = deprecate_property( - "face_boundary_indices", "faceBoundaryInd", removal_version="1.0.0", future_warn=False - ) - cellBoundaryInd = deprecate_property( - "cell_boundary_indices", "cellBoundaryInd", removal_version="1.0.0", future_warn=False - ) diff --git a/discretize/tests.py b/discretize/tests.py index ded844eac..17dd5c4c9 100644 --- a/discretize/tests.py +++ b/discretize/tests.py @@ -32,7 +32,6 @@ from discretize.tensor_mesh import TensorMesh from discretize.curvilinear_mesh import CurvilinearMesh from discretize.cylindrical_mesh import CylindricalMesh -from discretize.utils.code_utils import deprecate_function from . import TreeMesh as Tree @@ -749,14 +748,3 @@ def random(size, iscomplex): ) return passed - - -# DEPRECATIONS -setupMesh = deprecate_function(setup_mesh, "setupMesh", removal_version="1.0.0") -Rosenbrock = deprecate_function(rosenbrock, "Rosenbrock", removal_version="1.0.0") -checkDerivative = deprecate_function( - check_derivative, "checkDerivative", removal_version="1.0.0" -) -getQuadratic = deprecate_function( - get_quadratic, "getQuadratic", removal_version="1.0.0" -) diff --git a/discretize/tree_mesh.py b/discretize/tree_mesh.py index 6186c038d..78410a01c 100644 --- a/discretize/tree_mesh.py +++ b/discretize/tree_mesh.py @@ -93,7 +93,6 @@ import numpy as np import scipy.sparse as sp import warnings -from discretize.utils.code_utils import deprecate_property class TreeMesh( @@ -539,22 +538,8 @@ def cell_levels_by_index(self, indices): return self._cell_levels_by_indexes(indices) def get_interpolation_matrix( - self, locs, location_type="CC", zeros_outside=False, **kwargs + self, locs, location_type="CC", zeros_outside=False, ): - if "locType" in kwargs: - warnings.warn( - "The locType keyword argument has been deprecated, please use location_type. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - location_type = kwargs["locType"] - if "zerosOutside" in kwargs: - warnings.warn( - "The zerosOutside keyword argument has been deprecated, please use zeros_outside. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - zeros_outside = kwargs["zerosOutside"] locs = as_array_n_by_dim(locs, self.dim) if location_type not in ["N", "CC", "Ex", "Ey", "Ez", "Fx", "Fy", "Fz"]: raise Exception( @@ -655,65 +640,3 @@ def equals(self, other): def __reduce__(self): return TreeMesh, (self.h, self.origin), self.__getstate__() - - cellGrad = deprecate_property("cell_gradient", "cellGrad", removal_version="1.0.0", future_warn=False) - cellGradx = deprecate_property( - "cell_gradient_x", "cellGradx", removal_version="1.0.0", future_warn=False - ) - cellGrady = deprecate_property( - "cell_gradient_y", "cellGrady", removal_version="1.0.0", future_warn=False - ) - cellGradz = deprecate_property( - "cell_gradient_z", "cellGradz", removal_version="1.0.0", future_warn=False - ) - cellGradStencil = deprecate_property( - "cell_gradient_stencil", "cellGradStencil", removal_version="1.0.0", future_warn=False - ) - faceDivx = deprecate_property( - "face_x_divergence", "faceDivx", removal_version="1.0.0", future_warn=False - ) - faceDivy = deprecate_property( - "face_y_divergence", "faceDivy", removal_version="1.0.0", future_warn=False - ) - faceDivz = deprecate_property( - "face_z_divergence", "faceDivz", removal_version="1.0.0", future_warn=False - ) - maxLevel = deprecate_property("max_used_level", "maxLevel", removal_version="1.0.0", future_warn=False) - areaFx = deprecate_property("face_x_areas", "areaFx", removal_version="1.0.0", future_warn=False) - areaFy = deprecate_property("face_y_areas", "areaFy", removal_version="1.0.0", future_warn=False) - areaFz = deprecate_property("face_z_areas", "areaFz", removal_version="1.0.0", future_warn=False) - edgeEx = deprecate_property("edge_x_lengths", "edgeEx", removal_version="1.0.0", future_warn=False) - edgeEy = deprecate_property("edge_y_lengths", "edgeEy", removal_version="1.0.0", future_warn=False) - edgeEz = deprecate_property("edge_z_lengths", "edgeEz", removal_version="1.0.0", future_warn=False) - permuteCC = deprecate_property( - "permute_cells", "permuteCC", removal_version="1.0.0", future_warn=False - ) - permuteF = deprecate_property("permute_faces", "permuteF", removal_version="1.0.0", future_warn=False) - permuteE = deprecate_property("permute_edges", "permuteE", removal_version="1.0.0", future_warn=False) - faceBoundaryInd = deprecate_property( - "face_boundary_indices", "faceBoundaryInd", removal_version="1.0.0", future_warn=False - ) - cellBoundaryInd = deprecate_property( - "cell_boundary_indices", "cellBoundaryInd", removal_version="1.0.0", future_warn=False - ) - _aveCC2FxStencil = deprecate_property( - "average_cell_to_total_face_x", "_aveCC2FxStencil", removal_version="1.0.0", future_warn=False - ) - _aveCC2FyStencil = deprecate_property( - "average_cell_to_total_face_y", "_aveCC2FyStencil", removal_version="1.0.0", future_warn=False - ) - _aveCC2FzStencil = deprecate_property( - "average_cell_to_total_face_z", "_aveCC2FzStencil", removal_version="1.0.0", future_warn=False - ) - _cellGradStencil = deprecate_property( - "stencil_cell_gradient", "_cellGradStencil", removal_version="1.0.0", future_warn=False - ) - _cellGradxStencil = deprecate_property( - "stencil_cell_gradient_x", "_cellGradxStencil", removal_version="1.0.0", future_warn=False - ) - _cellGradyStencil = deprecate_property( - "stencil_cell_gradient_y", "_cellGradyStencil", removal_version="1.0.0", future_warn=False - ) - _cellGradzStencil = deprecate_property( - "stencil_cell_gradient_z", "_cellGradzStencil", removal_version="1.0.0", future_warn=False - ) diff --git a/discretize/utils/__init__.py b/discretize/utils/__init__.py index d4f09103b..ec259d4aa 100644 --- a/discretize/utils/__init__.py +++ b/discretize/utils/__init__.py @@ -152,25 +152,3 @@ ) from discretize.utils.io_utils import download, load_mesh - -# DEPRECATIONS -from discretize.utils.code_utils import isScalar, asArray_N_x_Dim -from discretize.utils.matrix_utils import ( - sdInv, - getSubArray, - inv3X3BlockDiagonal, - inv2X2BlockDiagonal, - makePropertyTensor, - invPropertyTensor, -) -from discretize.utils.mesh_utils import ( - meshTensor, - closestPoints, - ExtractCoreMesh, -) -from discretize.utils.curvilinear_utils import exampleLrmGrid, volTetra, indexCube, faceInfo -from discretize.utils.interpolation_utils import interpmat -from discretize.utils.coordinate_utils import ( - rotationMatrixFromNormals, - rotatePointsFromNormals, -) diff --git a/discretize/utils/code_utils.py b/discretize/utils/code_utils.py index 52107d823..6651fe135 100644 --- a/discretize/utils/code_utils.py +++ b/discretize/utils/code_utils.py @@ -259,10 +259,3 @@ def dep_function(*args, **kwargs): """ dep_function.__doc__ = doc return dep_function - - -# DEPRECATIONS -isScalar = deprecate_function(is_scalar, "isScalar", removal_version="1.0.0", future_warn=False) -asArray_N_x_Dim = deprecate_function( - as_array_n_by_dim, "asArray_N_x_Dim", removal_version="1.0.0", future_warn=False -) diff --git a/discretize/utils/codeutils.py b/discretize/utils/codeutils.py deleted file mode 100644 index e6d5615fb..000000000 --- a/discretize/utils/codeutils.py +++ /dev/null @@ -1,8 +0,0 @@ -from discretize.utils.code_utils import * -import warnings - -warnings.warn( - "Importing from discretize.codeutils is deprecated behavoir. Please import " - "from discretize.utils. This module will be removed in version 1.0.0 of discretize.", - DeprecationWarning, -) diff --git a/discretize/utils/coordinate_utils.py b/discretize/utils/coordinate_utils.py index 6f16b3bf7..b4fec652e 100644 --- a/discretize/utils/coordinate_utils.py +++ b/discretize/utils/coordinate_utils.py @@ -1,6 +1,6 @@ import numpy as np from discretize.utils.matrix_utils import mkvc -from discretize.utils.code_utils import as_array_n_by_dim, deprecate_function +from discretize.utils.code_utils import as_array_n_by_dim def cylindrical_to_cartesian(grid, vec=None): @@ -290,11 +290,3 @@ def rotate_points_from_normals(xyz, v0, v1, x0=np.r_[0.0, 0.0, 0.0]): X0 = np.ones([xyz.shape[0], 1]) * mkvc(x0) return (xyz - X0).dot(R.T) + X0 # equivalent to (R*(xyz - X0)).T + X0 - - -rotationMatrixFromNormals = deprecate_function( - rotation_matrix_from_normals, "rotationMatrixFromNormals", removal_version="1.0.0", future_warn=False -) -rotatePointsFromNormals = deprecate_function( - rotate_points_from_normals, "rotatePointsFromNormals", removal_version="1.0.0", future_warn=False -) diff --git a/discretize/utils/coordutils.py b/discretize/utils/coordutils.py deleted file mode 100644 index dfb82b57a..000000000 --- a/discretize/utils/coordutils.py +++ /dev/null @@ -1,8 +0,0 @@ -from discretize.utils.coordinate_utils import * -import warnings - -warnings.warn( - "Importing from discretize.coordutils is deprecated behavoir. Please import " - "from discretize.utils. This module will be removed in version 1.0.0 of discretize.", - DeprecationWarning, -) diff --git a/discretize/utils/curvilinear_utils.py b/discretize/utils/curvilinear_utils.py index dd47abe6d..be692979b 100644 --- a/discretize/utils/curvilinear_utils.py +++ b/discretize/utils/curvilinear_utils.py @@ -1,6 +1,5 @@ import numpy as np from discretize.utils.matrix_utils import mkvc, ndgrid, sub2ind -from discretize.utils.code_utils import deprecate_function import warnings @@ -307,7 +306,7 @@ def index_cube(nodes, grid_shape, n=None): return out -def face_info(xyz, A, B, C, D, average=True, normalize_normals=True, **kwargs): +def face_info(xyz, A, B, C, D, average=True, normalize_normals=True): """Returns normal surface vector and area for a given set of faces. Let *xyz* be an (n, 3) array denoting a set of vertex locations. @@ -460,13 +459,6 @@ def face_info(xyz, A, B, C, D, average=True, normalize_normals=True, **kwargs): ... ) >>> plt.show() """ - if "normalizeNormals" in kwargs: - warnings.warn( - "The normalizeNormals keyword argument has been deprecated, please use normalize_normals. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - normalize_normals = kwargs["normalizeNormals"] if not isinstance(average, bool): raise TypeError("average must be a boolean") if not isinstance(normalize_normals, bool): @@ -514,11 +506,3 @@ def cross(X, Y): area = (length(nA) + length(nB) + length(nC) + length(nD)) / 4 return N, area - - -exampleLrmGrid = deprecate_function( - example_curvilinear_grid, "exampleLrmGrid", removal_version="1.0.0", future_warn=False -) -volTetra = deprecate_function(volume_tetrahedron, "volTetra", removal_version="1.0.0", future_warn=False) -indexCube = deprecate_function(index_cube, "indexCube", removal_version="1.0.0", future_warn=False) -faceInfo = deprecate_function(face_info, "faceInfo", removal_version="1.0.0", future_warn=False) diff --git a/discretize/utils/curvutils.py b/discretize/utils/curvutils.py deleted file mode 100644 index 9872b5fa9..000000000 --- a/discretize/utils/curvutils.py +++ /dev/null @@ -1,8 +0,0 @@ -from discretize.utils.curvilinear_utils import * -import warnings - -warnings.warn( - "Importing from discretize.curvutils is deprecated behavoir. Please import " - "from discretize.utils. This module will be removed in version 1.0.0 of discretize.", - DeprecationWarning, -) diff --git a/discretize/utils/interpolation_utils.py b/discretize/utils/interpolation_utils.py index 2a99380b7..bbf6a53ea 100644 --- a/discretize/utils/interpolation_utils.py +++ b/discretize/utils/interpolation_utils.py @@ -1,7 +1,6 @@ import numpy as np import scipy.sparse as sp from discretize.utils.matrix_utils import mkvc, sub2ind -from discretize.utils.code_utils import deprecate_function try: from discretize._extensions import interputils_cython as pyx @@ -287,8 +286,3 @@ def volume_average(mesh_in, mesh_out, values=None, output=None): return mesh_out._vol_avg_from_tree(mesh_in, values, output) else: raise TypeError("Unsupported mesh types") - - -interpmat = deprecate_function( - interpolation_matrix, "interpmat", removal_version="1.0.0", future_warn=False -) diff --git a/discretize/utils/interputils.py b/discretize/utils/interputils.py deleted file mode 100644 index 04a043eb8..000000000 --- a/discretize/utils/interputils.py +++ /dev/null @@ -1,8 +0,0 @@ -from discretize.utils.interpolation_utils import * -import warnings - -warnings.warn( - "Importing from discretize.interputils is deprecated behavoir. Please import " - "from discretize.utils. This module will be removed in version 1.0.0 of discretize.", - DeprecationWarning, -) diff --git a/discretize/utils/matrix_utils.py b/discretize/utils/matrix_utils.py index d83d4e19f..c31ec2564 100644 --- a/discretize/utils/matrix_utils.py +++ b/discretize/utils/matrix_utils.py @@ -1,10 +1,10 @@ import numpy as np import scipy.sparse as sp -from discretize.utils.code_utils import is_scalar, deprecate_function +from discretize.utils.code_utils import is_scalar import warnings -def mkvc(x, n_dims=1, **kwargs): +def mkvc(x, n_dims=1): """Creates a vector with specified dimensionality. This function converts a :class:`numpy.ndarray` to a vector. In general, @@ -54,13 +54,6 @@ def mkvc(x, n_dims=1, **kwargs): Shape of output with n_dim = 2 : (6, 1) Shape of output with n_dim = 3 : (6, 1, 1) """ - if "numDims" in kwargs: - warnings.warn( - "The numDims keyword argument has been deprecated, please use n_dims. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - n_dims = kwargs["numDims"] if type(x) == np.matrix: x = np.array(x) @@ -596,7 +589,7 @@ def get_subarray(A, ind): def inverse_3x3_block_diagonal( - a11, a12, a13, a21, a22, a23, a31, a32, a33, return_matrix=True, **kwargs + a11, a12, a13, a21, a22, a23, a31, a32, a33, return_matrix=True, ): """Invert a set of 3x3 matricies from vectors containing their elements. @@ -704,13 +697,6 @@ def inverse_3x3_block_diagonal( >>> plt.spy(M) >>> plt.show() """ - if "returnMatrix" in kwargs: - warnings.warn( - "The returnMatrix keyword argument has been deprecated, please use return_matrix. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - return_matrix = kwargs["returnMatrix"] a11 = mkvc(a11) a12 = mkvc(a12) @@ -755,7 +741,7 @@ def inverse_3x3_block_diagonal( ) -def inverse_2x2_block_diagonal(a11, a12, a21, a22, return_matrix=True, **kwargs): +def inverse_2x2_block_diagonal(a11, a12, a21, a22, return_matrix=True): """ Invert a set of 2x2 matricies from vectors containing their elements. @@ -858,14 +844,6 @@ def inverse_2x2_block_diagonal(a11, a12, a21, a22, return_matrix=True, **kwargs) >>> plt.spy(M) >>> plt.show() """ - if "returnMatrix" in kwargs: - warnings.warn( - "The returnMatrix keyword argument has been deprecated, please use return_matrix. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - return_matrix = kwargs["returnMatrix"] - a11 = mkvc(a11) a12 = mkvc(a12) a21 = mkvc(a21) @@ -1231,7 +1209,7 @@ def make_property_tensor(mesh, tensor): return Sigma -def inverse_property_tensor(mesh, tensor, return_matrix=False, **kwargs): +def inverse_property_tensor(mesh, tensor, return_matrix=False): r"""Construct the inverse of the physical property tensor. For a given *mesh*, the input parameter *tensor* is a :class:`numpy.ndarray` @@ -1381,15 +1359,6 @@ def inverse_property_tensor(mesh, tensor, return_matrix=False, **kwargs): ... ) >>> plt.show() """ - - if "returnMatrix" in kwargs: - warnings.warn( - "The returnMatrix keyword argument has been deprecated, please use return_matrix. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - return_matrix = kwargs["returnMatrix"] - propType = TensorType(mesh, tensor) if is_scalar(tensor): @@ -1706,28 +1675,3 @@ def __len__(self): def __repr__(self): return f"({self._val}, {self._val}, ...)" - - -################################################ -# DEPRECATED FUNCTIONS -################################################ - -sdInv = deprecate_function(sdinv, "sdInv", removal_version="1.0.0", future_warn=False) - -getSubArray = deprecate_function(get_subarray, "getSubArray", removal_version="1.0.0", future_warn=False) - -inv3X3BlockDiagonal = deprecate_function( - inverse_3x3_block_diagonal, "inv3X3BlockDiagonal", removal_version="1.0.0", future_warn=False -) - -inv2X2BlockDiagonal = deprecate_function( - inverse_2x2_block_diagonal, "inv2X2BlockDiagonal", removal_version="1.0.0", future_warn=False -) - -makePropertyTensor = deprecate_function( - make_property_tensor, "makePropertyTensor", removal_version="1.0.0", future_warn=False -) - -invPropertyTensor = deprecate_function( - inverse_property_tensor, "invPropertyTensor", removal_version="1.0.0", future_warn=False -) diff --git a/discretize/utils/matutils.py b/discretize/utils/matutils.py deleted file mode 100644 index 7309c518e..000000000 --- a/discretize/utils/matutils.py +++ /dev/null @@ -1,8 +0,0 @@ -from discretize.utils.matrix_utils import * -import warnings - -warnings.warn( - "Importing from discretize.matutils is deprecated behavoir. Please import " - "from discretize.utils. This module will be removed in version 1.0.0 of discretize.", - DeprecationWarning, -) diff --git a/discretize/utils/mesh_utils.py b/discretize/utils/mesh_utils.py index a94a221dc..2090e855d 100644 --- a/discretize/utils/mesh_utils.py +++ b/discretize/utils/mesh_utils.py @@ -6,7 +6,6 @@ from scipy.spatial import cKDTree, Delaunay from scipy import interpolate import discretize -from discretize.utils.code_utils import deprecate_function import warnings num_types = [int, float] @@ -174,7 +173,7 @@ def unpack_widths(value): return np.array(proposed) -def closest_points_index(mesh, pts, grid_loc="CC", **kwargs): +def closest_points_index(mesh, pts, grid_loc="CC"): """Find the indicies for the nearest grid location for a set of points. Parameters @@ -225,13 +224,6 @@ def closest_points_index(mesh, pts, grid_loc="CC", **kwargs): >>> ax.scatter(xy_nodes[ind_nodes, 0], xy_nodes[ind_nodes, 1], 50, 'b') >>> plt.show() """ - if "gridLoc" in kwargs: - warnings.warn( - "The gridLoc keyword argument has been deprecated, please use grid_loc. " - "This will be removed in discretize 1.0.0", - DeprecationWarning, - ) - grid_loc = kwargs["gridLoc"] warnings.warn( "The closest_points_index utilty function has been moved to be a method of " "a class object. Please access it as mesh.closest_points_index(). This will " @@ -1151,15 +1143,3 @@ def example_simplex_mesh(rect_shape): ] return points, simplices - - -meshTensor = deprecate_function(unpack_widths, "meshTensor", removal_version="1.0.0", future_warn=False) -closestPoints = deprecate_function( - closest_points_index, "closestPoints", removal_version="1.0.0", future_warn=False -) -ExtractCoreMesh = deprecate_function( - extract_core_mesh, "ExtractCoreMesh", removal_version="1.0.0", future_warn=False -) -closest_points = deprecate_function( - closest_points_index, "closest_points", removal_version="1.0.0", future_warn=False -) diff --git a/discretize/utils/meshutils.py b/discretize/utils/meshutils.py deleted file mode 100644 index 2efdf5123..000000000 --- a/discretize/utils/meshutils.py +++ /dev/null @@ -1,8 +0,0 @@ -from discretize.utils.mesh_utils import * -import warnings - -warnings.warn( - "Importing from discretize.meshutils is deprecated behavoir. Please import " - "from discretize.utils. This module will be removed in version 1.0.0 of discretize.", - DeprecationWarning, -) From c4231fde7784b1e3f5569430343ee66d6ed12d94 Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Wed, 20 Apr 2022 12:00:04 -0700 Subject: [PATCH 02/16] fix test --- tests/simplex/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/simplex/test_utils.py b/tests/simplex/test_utils.py index d427dcc96..1d111996c 100644 --- a/tests/simplex/test_utils.py +++ b/tests/simplex/test_utils.py @@ -39,7 +39,7 @@ def test_init_errors(self): mesh = discretize.SimplexMesh(np.random.rand(10, 4), simplices[:, :-1]) def test_find_containing(self): - n = 8 + n = 4 points, simplices = example_simplex_mesh((n, n)) mesh = discretize.SimplexMesh(points, simplices) From 0edfd3789dab434d937b6dcd7b66eef81eaed587 Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Thu, 18 Aug 2022 12:33:56 -0700 Subject: [PATCH 03/16] fix merge --- discretize/base/base_tensor_mesh.py | 87 ----------------------------- 1 file changed, 87 deletions(-) diff --git a/discretize/base/base_tensor_mesh.py b/discretize/base/base_tensor_mesh.py index 5ea304d05..bc52233fc 100644 --- a/discretize/base/base_tensor_mesh.py +++ b/discretize/base/base_tensor_mesh.py @@ -772,23 +772,6 @@ def _getInterpolationMat( def get_interpolation_matrix( self, loc, location_type="cell_centers", zeros_outside=False, ): -<<<<<<< HEAD -======= - if "locType" in kwargs: - warnings.warn( - "The locType keyword argument has been deprecated, please use location_type. " - "This will be removed in discretize 1.0.0", - FutureWarning, - ) - location_type = kwargs["locType"] - if "zerosOutside" in kwargs: - warnings.warn( - "The zerosOutside keyword argument has been deprecated, please use zeros_outside. " - "This will be removed in discretize 1.0.0", - FutureWarning, - ) - zeros_outside = kwargs["zerosOutside"] ->>>>>>> main return self._getInterpolationMat(loc, location_type, zeros_outside) def _fastInnerProduct( @@ -1003,73 +986,3 @@ def innerProductDeriv(v=None): return innerProductDeriv else: return None -<<<<<<< HEAD -======= - - # DEPRECATED - @property - def hx(self): - """Width of cells in the x direction - - Returns - ------- - numpy.ndarray - - .. deprecated:: 0.5.0 - `hx` will be removed in discretize 1.0.0 to reduce namespace clutter, - please use `mesh.h[0]`. - """ - warnings.warn( - "hx has been deprecated, please access as mesh.h[0]", FutureWarning - ) - return self.h[0] - - @property - def hy(self): - """Width of cells in the y direction - - Returns - ------- - numpy.ndarray or None - - .. deprecated:: 0.5.0 - `hy` will be removed in discretize 1.0.0 to reduce namespace clutter, - please use `mesh.h[1]`. - """ - warnings.warn( - "hy has been deprecated, please access as mesh.h[1]", FutureWarning - ) - return None if self.dim < 2 else self.h[1] - - @property - def hz(self): - """Width of cells in the z direction - - Returns - ------- - numpy.ndarray or None - - .. deprecated:: 0.5.0 - `hz` will be removed in discretize 1.0.0 to reduce namespace clutter, - please use `mesh.h[2]`. - """ - warnings.warn( - "hz has been deprecated, please access as mesh.h[2]", FutureWarning - ) - return None if self.dim < 3 else self.h[2] - - vectorNx = deprecate_property("nodes_x", "vectorNx", removal_version="1.0.0", future_warn=True) - vectorNy = deprecate_property("nodes_y", "vectorNy", removal_version="1.0.0", future_warn=True) - vectorNz = deprecate_property("nodes_z", "vectorNz", removal_version="1.0.0", future_warn=True) - vectorCCx = deprecate_property( - "cell_centers_x", "vectorCCx", removal_version="1.0.0", future_warn=True - ) - vectorCCy = deprecate_property( - "cell_centers_y", "vectorCCy", removal_version="1.0.0", future_warn=True - ) - vectorCCz = deprecate_property( - "cell_centers_z", "vectorCCz", removal_version="1.0.0", future_warn=True - ) - isInside = deprecate_method("is_inside", "isInside", removal_version="1.0.0", future_warn=True) - getTensor = deprecate_method("get_tensor", "getTensor", removal_version="1.0.0", future_warn=True) ->>>>>>> main From 8706be7a56f815ebbcee7909c0898eab962289ab Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Thu, 18 Aug 2022 12:35:33 -0700 Subject: [PATCH 04/16] don't import CylMesh --- discretize/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discretize/__init__.py b/discretize/__init__.py index 3b2c5aed9..03502e07a 100644 --- a/discretize/__init__.py +++ b/discretize/__init__.py @@ -31,7 +31,7 @@ """ from discretize.tensor_mesh import TensorMesh -from discretize.cylindrical_mesh import CylMesh, CylindricalMesh +from discretize.cylindrical_mesh import CylindricalMesh from discretize.curvilinear_mesh import CurvilinearMesh from discretize.unstructured_mesh import SimplexMesh from discretize.utils.io_utils import load_mesh From bb1bf3cd0ec0e8631fa41bf3518c436a4e221f5d Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Thu, 26 Jan 2023 22:29:45 -0800 Subject: [PATCH 05/16] Run black --- discretize/base/base_tensor_mesh.py | 2 +- discretize/cylindrical_mesh.py | 12 +++++++++--- discretize/mixins/vtk_mod.py | 2 ++ discretize/operators/differential_operators.py | 1 - discretize/utils/matrix_utils.py | 11 ++++++++++- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/discretize/base/base_tensor_mesh.py b/discretize/base/base_tensor_mesh.py index 70ac9585e..fa4e219a1 100644 --- a/discretize/base/base_tensor_mesh.py +++ b/discretize/base/base_tensor_mesh.py @@ -977,4 +977,4 @@ def innerProductDeriv(v=None): return innerProductDeriv else: - return None \ No newline at end of file + return None diff --git a/discretize/cylindrical_mesh.py b/discretize/cylindrical_mesh.py index 07139492d..220fa2fe6 100644 --- a/discretize/cylindrical_mesh.py +++ b/discretize/cylindrical_mesh.py @@ -1630,7 +1630,10 @@ def _deflation_matrix(self, location, as_ones=False): #################################################### def get_interpolation_matrix( - self, loc, location_type="cell_centers", zeros_outside=False, + self, + loc, + location_type="cell_centers", + zeros_outside=False, ): r"""Construct interpolation matrix from mesh. @@ -1864,7 +1867,10 @@ def cartesian_grid(self, location_type="cell_centers", theta_shift=None): return cyl2cart(grid) # TODO: account for cartesian origin def get_interpolation_matrix_cartesian_mesh( - self, Mrect, location_type="cell_centers", location_type_to=None, + self, + Mrect, + location_type="cell_centers", + location_type_to=None, ): """Construct projection matrix from ``CylindricalMesh`` to other mesh. @@ -1969,4 +1975,4 @@ def get_interpolation_matrix_cartesian_mesh( Pc2r = self.get_interpolation_matrix(G, interp_type) Proj = sdiag(proj) - return Proj * Pc2r \ No newline at end of file + return Proj * Pc2r diff --git a/discretize/mixins/vtk_mod.py b/discretize/mixins/vtk_mod.py index 54c0cfae1..16063a542 100644 --- a/discretize/mixins/vtk_mod.py +++ b/discretize/mixins/vtk_mod.py @@ -609,6 +609,7 @@ def to_vtk(mesh, models=None): "For easier use of VTK objects, you should install `pyvista` (the VTK interface): pip install pyvista" ) return cvtd + @staticmethod def _save_unstructured_grid(file_name, vtkUnstructGrid, directory=""): """Save an unstructured grid to a vtk file. @@ -760,6 +761,7 @@ def write_vtk(mesh, file_name, models=None, directory=""): raise RuntimeError("VTK data type `%s` is not currently supported." % key) return write(file_name, vtkObj, directory=directory) + class InterfaceTensorread_vtk(object): """Mixin class for converting vtk to TensorMesh. diff --git a/discretize/operators/differential_operators.py b/discretize/operators/differential_operators.py index a6aacb59c..23420459d 100644 --- a/discretize/operators/differential_operators.py +++ b/discretize/operators/differential_operators.py @@ -1754,7 +1754,6 @@ def cell_gradient_weak_form_robin(self, alpha=0.0, beta=1.0, gamma=0.0): return A, b - @property def cell_gradient_x(self): r"""X-derivative operator (cell centers to x-faces). diff --git a/discretize/utils/matrix_utils.py b/discretize/utils/matrix_utils.py index 28f15a0db..502dd7e56 100644 --- a/discretize/utils/matrix_utils.py +++ b/discretize/utils/matrix_utils.py @@ -596,7 +596,16 @@ def get_subarray(A, ind): def inverse_3x3_block_diagonal( - a11, a12, a13, a21, a22, a23, a31, a32, a33, return_matrix=True, + a11, + a12, + a13, + a21, + a22, + a23, + a31, + a32, + a33, + return_matrix=True, ): r"""Invert a set of 3x3 matricies from vectors containing their elements. From 5ec5f9d9d248e60a5dcab305dc880ed90a0dce91 Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Thu, 26 Jan 2023 22:35:56 -0800 Subject: [PATCH 06/16] Style updates --- discretize/base/base_mesh.py | 8 -------- discretize/cylindrical_mesh.py | 2 -- discretize/operators/inner_products.py | 1 - discretize/tests.py | 2 +- discretize/tree_mesh.py | 2 +- discretize/utils/curvilinear_utils.py | 1 - discretize/utils/matrix_utils.py | 12 +----------- 7 files changed, 3 insertions(+), 25 deletions(-) diff --git a/discretize/base/base_mesh.py b/discretize/base/base_mesh.py index 9b8d89ddd..f53d28fba 100644 --- a/discretize/base/base_mesh.py +++ b/discretize/base/base_mesh.py @@ -161,14 +161,6 @@ def save(self, file_name="mesh.json", verbose=False): verbose : bool, optional If *True*, the path of the json file is printed """ - - if "filename" in kwargs: - file_name = kwargs["filename"] - warnings.warn( - "The filename keyword argument has been deprecated, please use file_name. " - "This will be removed in discretize 1.0.0", - FutureWarning, - ) f = os.path.abspath(file_name) # make sure we are working with abs path with open(f, "w") as outfile: json.dump(self.to_dict(), outfile) diff --git a/discretize/cylindrical_mesh.py b/discretize/cylindrical_mesh.py index 220fa2fe6..7e993570c 100644 --- a/discretize/cylindrical_mesh.py +++ b/discretize/cylindrical_mesh.py @@ -19,7 +19,6 @@ from discretize.base import BaseTensorMesh, BaseRectangularMesh from discretize.operators import DiffOperators, InnerProducts from discretize.mixins import InterfaceMixins -import warnings class CylindricalMesh( @@ -1673,7 +1672,6 @@ def get_interpolation_matrix( The interpolation matrix """ - location_type = self._parse_location_type(location_type) if self.is_symmetric and location_type in ["edges_x", "edges_z", "faces_y"]: raise ValueError( diff --git a/discretize/operators/inner_products.py b/discretize/operators/inner_products.py index 9e7ede30d..eda2100d3 100644 --- a/discretize/operators/inner_products.py +++ b/discretize/operators/inner_products.py @@ -14,7 +14,6 @@ sdinv, ) import numpy as np -import warnings class InnerProducts(object): diff --git a/discretize/tests.py b/discretize/tests.py index 16f70b778..188b69976 100644 --- a/discretize/tests.py +++ b/discretize/tests.py @@ -313,7 +313,7 @@ def setupMesh(self, nC): Float Maximum cell width for the mesh """ - mesh, max_h = setupMesh(self._meshType, nC, self.meshDimension) + mesh, max_h = setup_mesh(self._meshType, nC, self.meshDimension) self.M = mesh return max_h diff --git a/discretize/tree_mesh.py b/discretize/tree_mesh.py index 3d9e49559..422587d6c 100644 --- a/discretize/tree_mesh.py +++ b/discretize/tree_mesh.py @@ -93,7 +93,7 @@ from discretize._extensions.tree_ext import _TreeMesh, TreeCell # NOQA F401 import numpy as np import scipy.sparse as sp -import warnings +from scipy.spatial import Delaunay class TreeMesh( diff --git a/discretize/utils/curvilinear_utils.py b/discretize/utils/curvilinear_utils.py index f94368b83..a60e6328b 100644 --- a/discretize/utils/curvilinear_utils.py +++ b/discretize/utils/curvilinear_utils.py @@ -1,7 +1,6 @@ """Functions for working with curvilinear meshes.""" import numpy as np from discretize.utils.matrix_utils import mkvc, ndgrid, sub2ind -import warnings def example_curvilinear_grid(nC, exType): diff --git a/discretize/utils/matrix_utils.py b/discretize/utils/matrix_utils.py index 502dd7e56..50ca6d034 100644 --- a/discretize/utils/matrix_utils.py +++ b/discretize/utils/matrix_utils.py @@ -2,7 +2,6 @@ import numpy as np import scipy.sparse as sp from discretize.utils.code_utils import is_scalar -import warnings def mkvc(x, n_dims=1): @@ -373,7 +372,7 @@ def ndgrid(*args, vector=True, order="F"): return meshed -def make_boundary_bool(shape, bdir="xyz", **kwargs): +def make_boundary_bool(shape, bdir="xyz"): r"""Return boundary indices of a tensor grid. For a tensor grid whose shape is given (1D, 2D or 3D), this function @@ -433,14 +432,6 @@ def make_boundary_bool(shape, bdir="xyz", **kwargs): [1, 6], [3, 6]]) """ - old_dir = kwargs.pop("dir", None) - if old_dir is not None: - warnings.warn( - "The `dir` keyword argument has been renamed to `bdir` to avoid shadowing the " - "builtin variable `dir`. This will be removed in discretize 1.0.0", - FutureWarning, - ) - bdir = old_dir is_b = np.zeros(shape, dtype=bool, order="F") if "x" in bdir: is_b[[0, -1]] = True @@ -712,7 +703,6 @@ def inverse_3x3_block_diagonal( >>> plt.spy(M) >>> plt.show() """ - a11 = mkvc(a11) a12 = mkvc(a12) a13 = mkvc(a13) From 1330247be51e2a43680cdef0502bc3d80ce1faf3 Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Fri, 27 Jan 2023 16:09:19 -0800 Subject: [PATCH 07/16] Remove calls to deprecated functions in discretize --- discretize/_extensions/tree_ext.pyx | 26 ++++++++--------- discretize/base/base_regular_mesh.py | 28 +++++++++---------- discretize/base/base_tensor_mesh.py | 14 +++++----- discretize/curvilinear_mesh.py | 28 +++++++++---------- discretize/cylindrical_mesh.py | 2 -- discretize/mixins/mpl_mod.py | 24 ++++++++-------- discretize/mixins/omf_mod.py | 2 +- discretize/mixins/vtk_mod.py | 4 +-- .../operators/differential_operators.py | 12 ++++---- discretize/tests.py | 6 ++-- discretize/tree_mesh.py | 8 +++--- discretize/utils/mesh_utils.py | 8 +++--- 12 files changed, 80 insertions(+), 82 deletions(-) diff --git a/discretize/_extensions/tree_ext.pyx b/discretize/_extensions/tree_ext.pyx index 0c5e78da1..2a2b0914f 100644 --- a/discretize/_extensions/tree_ext.pyx +++ b/discretize/_extensions/tree_ext.pyx @@ -879,15 +879,15 @@ cdef class _TreeMesh: >>> triangle = [[0.14, 0.31, 0.21], [0.32, 0.96, 0.34], [0.87, 0.23, 0.12]] >>> height = 0.35 >>> levels = 5 - >>> mesh.refine_vertical_trianglular_prism(triangle, height, levels) + >>> tree_mesh.refine_vertical_trianglular_prism(triangle, height, levels) Now lets look at the mesh. - >>> v = mesh.cell_levels_by_index(np.arange(mesh.n_cells)) + >>> v = tree_mesh.cell_levels_by_index(np.arange(tree_mesh.n_cells)) >>> fig, axs = plt.subplots(1, 3, figsize=(12,4)) - >>> mesh.plot_slice(v, ax=axs[0], normal='x', grid=True, clim=[2, 5]) - >>> mesh.plot_slice(v, ax=axs[1], normal='y', grid=True, clim=[2, 5]) - >>> mesh.plot_slice(v, ax=axs[2], normal='z', grid=True, clim=[2, 5]) + >>> tree_mesh.plot_slice(v, ax=axs[0], normal='x', grid=True, clim=[2, 5]) + >>> tree_mesh.plot_slice(v, ax=axs[1], normal='y', grid=True, clim=[2, 5]) + >>> tree_mesh.plot_slice(v, ax=axs[2], normal='z', grid=True, clim=[2, 5]) >>> plt.show() """ @@ -5343,7 +5343,7 @@ cdef class _TreeMesh: return self._getEdgeP(xEdge, yEdge, zEdge) return Pxxx - def _getEdgeIntMat(self, locs, zerosOutside, direction): + def _getEdgeIntMat(self, locs, zeros_outside, direction): cdef: double[:, :] locations = locs int_t dir, dir1, dir2 @@ -5364,7 +5364,7 @@ cdef class _TreeMesh: double x, y, z double w1, w2, w3 double eps = 100*np.finfo(float).eps - int zeros_out = zerosOutside + int zeros_out = zeros_outside if direction == 'x': dir, dir1, dir2 = 0, 1, 2 @@ -5477,7 +5477,7 @@ cdef class _TreeMesh: A = sp.csr_matrix((data, indices, indptr), shape=(locs.shape[0], self.n_total_edges)) return A*Re - def _getFaceIntMat(self, locs, zerosOutside, direction): + def _getFaceIntMat(self, locs, zeros_outside, direction): cdef: double[:, :] locations = locs int_t dir, dir1, dir2, temp @@ -5496,7 +5496,7 @@ cdef class _TreeMesh: double x, y, z double w1, w2, w3 double eps = 100*np.finfo(float).eps - int zeros_out = zerosOutside + int zeros_out = zeros_outside if direction == 'x': dir = 0 @@ -5673,7 +5673,7 @@ cdef class _TreeMesh: Rf = self._deflate_faces() return sp.csr_matrix((data, indices, indptr), shape=(locs.shape[0], self.n_total_faces))*Rf - def _getNodeIntMat(self, locs, zerosOutside): + def _getNodeIntMat(self, locs, zeros_outside): cdef: double[:, :] locations = locs int_t dim = self._dim @@ -5688,7 +5688,7 @@ cdef class _TreeMesh: double x, y, z double wx, wy, wz double eps = 100*np.finfo(float).eps - int zeros_out = zerosOutside + int zeros_out = zeros_outside for i in range(n_loc): x = locations[i, 0] @@ -5738,7 +5738,7 @@ cdef class _TreeMesh: Rn = self._deflate_nodes() return sp.csr_matrix((V, (I, J)), shape=(locs.shape[0],self.n_total_nodes))*Rn - def _getCellIntMat(self, locs, zerosOutside): + def _getCellIntMat(self, locs, zeros_outside): cdef: double[:, :] locations = locs int_t dim = self._dim @@ -5758,7 +5758,7 @@ cdef class _TreeMesh: c_Cell *cell double x, y, z double eps = 100*np.finfo(float).eps - int zeros_out = zerosOutside + int zeros_out = zeros_outside dir0 = 0 dir1 = 1 diff --git a/discretize/base/base_regular_mesh.py b/discretize/base/base_regular_mesh.py index ac2878a7f..278fb1bfc 100644 --- a/discretize/base/base_regular_mesh.py +++ b/discretize/base/base_regular_mesh.py @@ -803,28 +803,28 @@ def reshape( "edges_z", ] if not (isinstance(x, list) or isinstance(x, np.ndarray)): - raise Exception("x must be either a list or a ndarray") + raise TypeError("x must be either a list or a ndarray") if x_type not in allowed_x_type: - raise Exception( + raise ValueError( "x_type must be either '" + "', '".join(allowed_x_type) + "'" ) if out_type not in allowed_x_type: - raise Exception( + raise ValueError( "out_type must be either '" + "', '".join(allowed_x_type) + "'" ) if return_format not in ["M", "V"]: - raise Exception("return_format must be either 'M' or 'V'") + raise ValueError("return_format must be either 'M' or 'V'") if out_type[: len(x_type)] != x_type: - raise Exception("You cannot change types when reshaping.") + raise ValueError("You cannot change types when reshaping.") if x_type not in out_type: - raise Exception("You cannot change type of components.") + raise ValueError("You cannot change type of components.") if isinstance(x, list): for i, xi in enumerate(x): if not isinstance(x, np.ndarray): - raise Exception("x[{0:d}] must be a numpy array".format(i)) + raise TypeError("x[{0:d}] must be a numpy array".format(i)) if xi.size != x[0].size: - raise Exception("Number of elements in list must not change.") + raise ValueError("Number of elements in list must not change.") x_array = np.ones((x.size, len(x))) # Unwrap it and put it in a np array @@ -833,7 +833,7 @@ def reshape( x = x_array if not isinstance(x, np.ndarray): - raise Exception("x must be a numpy array") + raise TypeError("x must be a numpy array") x = x[:] # make a copy. x_type_is_FE_xyz = ( @@ -854,7 +854,7 @@ def switchKernal(xx): if x_type in ["cell_centers", "nodes"]: nn = self.shape_cells if x_type == "cell_centers" else self.shape_nodes if xx.size != np.prod(nn): - raise Exception("Number of elements must not change.") + raise ValueError("Number of elements must not change.") return outKernal(xx, nn) elif x_type in ["faces", "edges"]: # This will only deal with components of fields, @@ -874,12 +874,12 @@ def switchKernal(xx): for dim, dimName in enumerate(["x", "y", "z"]): if dimName in out_type: if self.dim <= dim: - raise Exception( + raise ValueError( "Dimensions of mesh not great enough for " "{}_{}".format(x_type, dimName) ) if xx.size != np.sum(nn): - raise Exception("Vector is not the right size.") + raise ValueError("Vector is not the right size.") start = np.sum(nn[: dim + 1]) end = np.sum(nn[: dim + 2]) return outKernal(xx[start:end], nx[dim]) @@ -894,7 +894,7 @@ def switchKernal(xx): elif "z" in x_type: nn = self.shape_faces_z if "f" in x_type else self.shape_edges_z if xx.size != np.prod(nn): - raise Exception( + raise ValueError( f"Vector is not the right size. Expected {np.prod(nn)}, got {xx.size}" ) return outKernal(xx, nn) @@ -904,7 +904,7 @@ def switchKernal(xx): if out_type in ["faces", "edges"]: if isVectorQuantity: - raise Exception("Not sure what to do with a vector vector quantity..") + raise ValueError("Not sure what to do with a vector vector quantity..") outTypeCopy = out_type out = () for dirName in ["x", "y", "z"][: self.dim]: diff --git a/discretize/base/base_tensor_mesh.py b/discretize/base/base_tensor_mesh.py index fa4e219a1..c44915419 100644 --- a/discretize/base/base_tensor_mesh.py +++ b/discretize/base/base_tensor_mesh.py @@ -553,9 +553,9 @@ def boundary_edges(self): ey = ndgrid(self.nodes_x[[0, -1]], self.cell_centers_y) return np.r_[ex, ey] if dim == 3: - ex = self.edges_x[make_boundary_bool(self.shape_edges_x, dir="yz")] - ey = self.edges_y[make_boundary_bool(self.shape_edges_y, dir="xz")] - ez = self.edges_z[make_boundary_bool(self.shape_edges_z, dir="xy")] + ex = self.edges_x[make_boundary_bool(self.shape_edges_x, bdir="yz")] + ey = self.edges_y[make_boundary_bool(self.shape_edges_y, bdir="xz")] + ez = self.edges_z[make_boundary_bool(self.shape_edges_z, bdir="xy")] return np.r_[ex, ey, ez] def _getTensorGrid(self, key): @@ -675,7 +675,7 @@ def is_inside(self, pts, location_type="nodes"): ) return inside - def _getInterpolationMat( + def _get_interpolation_matrix( self, loc, location_type="cell_centers", zeros_outside=False ): """Produce an interpolation matrix. @@ -755,7 +755,7 @@ def _getInterpolationMat( else: raise NotImplementedError( - "getInterpolationMat: location_type==" + "get_interpolation_matrix: location_type==" + location_type + " and mesh.dim==" + str(self.dim) @@ -770,12 +770,12 @@ def get_interpolation_matrix( # NOQA D102 self, loc, location_type="cell_centers", zeros_outside=False ): # Documentation inherited from discretize.base.BaseMesh - return self._getInterpolationMat(loc, location_type, zeros_outside) + return self._get_interpolation_matrix(loc, location_type, zeros_outside) def _fastInnerProduct( self, projection_type, model=None, invert_model=False, invert_matrix=False ): - """Fast version of getFaceInnerProduct. + """Fast version of get_face_inner_product_deriv. This does not handle the case of a full tensor property. diff --git a/discretize/curvilinear_mesh.py b/discretize/curvilinear_mesh.py index 5510a5b92..24866a3a4 100644 --- a/discretize/curvilinear_mesh.py +++ b/discretize/curvilinear_mesh.py @@ -506,24 +506,24 @@ def boundary_nodes(self): # NOQA D102 def boundary_edges(self): # NOQA D102 # Documentation inherited from discretize.base.BaseMesh if self.dim == 2: - ex = self.edges_x[make_boundary_bool(self.shape_edges_x, dir="y")] - ey = self.edges_y[make_boundary_bool(self.shape_edges_y, dir="x")] + ex = self.edges_x[make_boundary_bool(self.shape_edges_x, bdir="y")] + ey = self.edges_y[make_boundary_bool(self.shape_edges_y, bdir="x")] return np.r_[ex, ey] elif self.dim == 3: - ex = self.edges_x[make_boundary_bool(self.shape_edges_x, dir="yz")] - ey = self.edges_y[make_boundary_bool(self.shape_edges_y, dir="xz")] - ez = self.edges_z[make_boundary_bool(self.shape_edges_z, dir="xy")] + ex = self.edges_x[make_boundary_bool(self.shape_edges_x, bdir="yz")] + ey = self.edges_y[make_boundary_bool(self.shape_edges_y, bdir="xz")] + ez = self.edges_z[make_boundary_bool(self.shape_edges_z, bdir="xy")] return np.r_[ex, ey, ez] @property def boundary_faces(self): # NOQA D102 # Documentation inherited from discretize.base.BaseMesh - fx = self.faces_x[make_boundary_bool(self.shape_faces_x, dir="x")] - fy = self.faces_y[make_boundary_bool(self.shape_faces_y, dir="y")] + fx = self.faces_x[make_boundary_bool(self.shape_faces_x, bdir="x")] + fy = self.faces_y[make_boundary_bool(self.shape_faces_y, bdir="y")] if self.dim == 2: return np.r_[fx, fy] elif self.dim == 3: - fz = self.faces_z[make_boundary_bool(self.shape_faces_z, dir="z")] + fz = self.faces_z[make_boundary_bool(self.shape_faces_z, bdir="z")] return np.r_[fx, fy, fz] @property @@ -538,8 +538,8 @@ def boundary_face_outward_normals(self): # NOQA D102 is_bym = is_bym.reshape(-1, order="F") is_b = np.r_[ - make_boundary_bool(self.shape_faces_x, dir="x"), - make_boundary_bool(self.shape_faces_y, dir="y"), + make_boundary_bool(self.shape_faces_x, bdir="x"), + make_boundary_bool(self.shape_faces_y, bdir="y"), ] switch = np.r_[is_bxm, is_bym] if self.dim == 3: @@ -547,7 +547,7 @@ def boundary_face_outward_normals(self): # NOQA D102 is_bzm[:, :, 0] = True is_bzm = is_bzm.reshape(-1, order="F") - is_b = np.r_[is_b, make_boundary_bool(self.shape_faces_z, dir="z")] + is_b = np.r_[is_b, make_boundary_bool(self.shape_faces_z, bdir="z")] switch = np.r_[switch, is_bzm] face_normals = self.face_normals.copy() face_normals[switch] *= -1 @@ -647,17 +647,17 @@ def face_areas(self): # NOQA D102 elif self.dim == 3: A, E, F, B = index_cube("AEFB", self.vnN, self.vnFx) normal1, area1 = face_info( - self.gridN, A, E, F, B, average=False, normalizeNormals=False + self.gridN, A, E, F, B, average=False, normalize_normals=False ) A, D, H, E = index_cube("ADHE", self.vnN, self.vnFy) normal2, area2 = face_info( - self.gridN, A, D, H, E, average=False, normalizeNormals=False + self.gridN, A, D, H, E, average=False, normalize_normals=False ) A, B, C, D = index_cube("ABCD", self.vnN, self.vnFz) normal3, area3 = face_info( - self.gridN, A, B, C, D, average=False, normalizeNormals=False + self.gridN, A, B, C, D, average=False, normalize_normals=False ) self._face_areas = np.r_[mkvc(area1), mkvc(area2), mkvc(area3)] diff --git a/discretize/cylindrical_mesh.py b/discretize/cylindrical_mesh.py index 7e993570c..6d1a6d2c3 100644 --- a/discretize/cylindrical_mesh.py +++ b/discretize/cylindrical_mesh.py @@ -126,8 +126,6 @@ class CylindricalMesh( def __init__(self, h, origin=None, cartesian_origin=None, **kwargs): kwargs.pop("reference_system", None) # reference system must be cylindrical - if "cartesianOrigin" in kwargs.keys(): - cartesian_origin = kwargs.pop("cartesianOrigin") super().__init__(h=h, origin=origin, reference_system="cylindrical", **kwargs) if not np.abs(self.h[1].sum() - 2 * np.pi) < 1e-10: diff --git a/discretize/mixins/mpl_mod.py b/discretize/mixins/mpl_mod.py index 4e7a50f7a..8169c0072 100644 --- a/discretize/mixins/mpl_mod.py +++ b/discretize/mixins/mpl_mod.py @@ -108,7 +108,7 @@ def plot_grid( >>> from matplotlib import pyplot as plt >>> import discretize - >>> X, Y = discretize.utils.exampleLrmGrid([10, 10], 'rotate') + >>> X, Y = discretize.utils.example_curvilinear_grid([10, 10], 'rotate') >>> M = discretize.CurvilinearMesh([X, Y]) >>> M.plot_grid() >>> plt.show() @@ -117,7 +117,7 @@ def plot_grid( >>> from matplotlib import pyplot as plt >>> import discretize - >>> X, Y, Z = discretize.utils.exampleLrmGrid([5, 5, 5], 'rotate') + >>> X, Y, Z = discretize.utils.example_curvilinear_grid([5, 5, 5], 'rotate') >>> M = discretize.CurvilinearMesh([X, Y, Z]) >>> M.plot_grid() >>> plt.show() @@ -560,7 +560,7 @@ def plot_slice( "v_type must be in ['{0!s}']".format("', '".join(v_typeOpts)) ) if not self.dim == 3: - raise TypeError("Must be a 3D mesh. Use plotImage.") + raise TypeError("Must be a 3D mesh. Use plot_image.") if view not in viewOpts: raise ValueError("view must be in ['{0!s}']".format("', '".join(viewOpts))) if normal not in normalOpts: @@ -574,7 +574,7 @@ def plot_slice( raise NotImplementedError("Can not plot a complex vector.") if self.dim == 2: - raise NotImplementedError("Must be a 3D mesh. Use plotImage.") + raise NotImplementedError("Must be a 3D mesh. Use plot_image.") # slice_loc errors if (ind is not None) and (slice_loc is not None): @@ -1426,9 +1426,9 @@ def __plot_grid_cyl(self, *args, **kwargs): # if slc is None, provide slices in both the theta and z directions if slc == "theta": - return self.__plotGridThetaSlice(*args, **kwargs) + return self.__plot_gridThetaSlice(*args, **kwargs) elif slc == "z": - return self.__plotGridZSlice(*args, **kwargs) + return self.__plot_gridZSlice(*args, **kwargs) else: ax = kwargs.pop("ax", None) if ax is not None: @@ -1476,19 +1476,19 @@ def __plot_grid_cyl(self, *args, **kwargs): kwargscart["ax"] = cartax ax = [] - ax.append(self.__plotGridZSlice(*args, **kwargspolar)) - ax.append(self.__plotGridThetaSlice(*args, **kwargscart)) + ax.append(self.__plot_gridZSlice(*args, **kwargspolar)) + ax.append(self.__plot_gridThetaSlice(*args, **kwargscart)) plt.tight_layout() return ax - def __plotGridThetaSlice(self, *args, **kwargs): + def __plot_gridThetaSlice(self, *args, **kwargs): # make a cyl symmetric mesh h2d = [self.h[0], 1, self.h[2]] mesh2D = self.__class__(h=h2d, origin=self.origin) return mesh2D.plot_grid(*args, **kwargs) - def __plotGridZSlice(self, *args, **kwargs): + def __plot_gridZSlice(self, *args, **kwargs): _, plt = load_matplotlib() # https://github.com/matplotlib/matplotlib/issues/312 ax = kwargs.get("ax", None) @@ -1905,7 +1905,7 @@ def __plot_image_tree( if self.dim == 3: raise NotImplementedError( - "plotImage is not implemented for 3D TreeMesh, please use plotSlice" + "plot_image is not implemented for 3D TreeMesh, please use plot_slice" ) # reshape to cell_centered thing if v_type == "CC": @@ -2346,7 +2346,7 @@ def __init__( # (a) Mesh dimensionality if mesh.dim != 3: - err = "Must be a 3D mesh. Use plotImage instead." + err = "Must be a 3D mesh. Use plot_image instead." err += " Mesh provided has {} dimension(s).".format(mesh.dim) raise ValueError(err) diff --git a/discretize/mixins/omf_mod.py b/discretize/mixins/omf_mod.py index 815b93e76..8da3b54cf 100644 --- a/discretize/mixins/omf_mod.py +++ b/discretize/mixins/omf_mod.py @@ -53,7 +53,7 @@ def _ravel_data_array(arr, nx, ny, nz): >>> hz = 3*np.ones(2) >>> mesh = TensorMesh([hx, hy, hz]) - >>> dim = (mesh.nCz, mesh.nCy, mesh.nCx) # OMF orderting + >>> dim = mesh.shape_cells[::-1] # OMF orderting >>> xc = np.reshape(mesh.cell_centers[:, 0], dim, order="C").ravel(order="F") >>> yc = np.reshape(mesh.cell_centers[:, 1], dim, order="C").ravel(order="F") >>> zc = np.reshape(mesh.cell_centers[:, 2], dim, order="C").ravel(order="F") diff --git a/discretize/mixins/vtk_mod.py b/discretize/mixins/vtk_mod.py index 16063a542..9ab937984 100644 --- a/discretize/mixins/vtk_mod.py +++ b/discretize/mixins/vtk_mod.py @@ -146,7 +146,7 @@ class InterfaceVTK(object): Save this mesh to a VTK file - >>> mesh.writeVTK('sample_mesh') + >>> mesh.write_vtk('sample_mesh') Here, the reference frame of the mesh is rotated. In this case, conversion to VTK produces a :class:`pyvista.StructuredGrid` object. @@ -166,7 +166,7 @@ class InterfaceVTK(object): or write it out to a VTK format - >>> mesh.writeVTK('sample_rotated') + >>> mesh.write_vtk('sample_rotated') The two above code snippets produced a :class:`pyvista.RectilinearGrid` and a :class:`pyvista.StructuredGrid` respecitvely. To demonstarte the difference, we diff --git a/discretize/operators/differential_operators.py b/discretize/operators/differential_operators.py index ee2c3c607..d77b4282c 100644 --- a/discretize/operators/differential_operators.py +++ b/discretize/operators/differential_operators.py @@ -3423,11 +3423,11 @@ def project_face_to_boundary_face(self): # NOQA D102 # Create a matrix that projects all faces onto boundary faces # The below should work for a regular structured mesh - is_b = make_boundary_bool(self.shape_faces_x, dir="x") + is_b = make_boundary_bool(self.shape_faces_x, bdir="x") if self.dim > 1: - is_b = np.r_[is_b, make_boundary_bool(self.shape_faces_y, dir="y")] + is_b = np.r_[is_b, make_boundary_bool(self.shape_faces_y, bdir="y")] if self.dim == 3: - is_b = np.r_[is_b, make_boundary_bool(self.shape_faces_z, dir="z")] + is_b = np.r_[is_b, make_boundary_bool(self.shape_faces_z, bdir="z")] return sp.eye(self.n_faces, format="csr")[is_b] @property @@ -3442,11 +3442,11 @@ def project_edge_to_boundary_edge(self): # NOQA D102 return None # No edges are on the boundary in 1D is_b = np.r_[ - make_boundary_bool(self.shape_edges_x, dir="yz"), - make_boundary_bool(self.shape_edges_y, dir="xz"), + make_boundary_bool(self.shape_edges_x, bdir="yz"), + make_boundary_bool(self.shape_edges_y, bdir="xz"), ] if self.dim == 3: - is_b = np.r_[is_b, make_boundary_bool(self.shape_edges_z, dir="xy")] + is_b = np.r_[is_b, make_boundary_bool(self.shape_edges_z, bdir="xy")] return sp.eye(self.n_edges, format="csr")[is_b] @property diff --git a/discretize/tests.py b/discretize/tests.py index 01c893523..b50694365 100644 --- a/discretize/tests.py +++ b/discretize/tests.py @@ -498,8 +498,8 @@ def check_derivative( >>> def simplePass(x): ... return np.sin(x), utils.sdiag(np.cos(x)) - >>> passed = tests.checkDerivative(simplePass, np.random.randn(5)) - ==================== checkDerivative ==================== + >>> passed = tests.check_derivative(simplePass, np.random.randn(5)) + ==================== check_derivative ==================== iter h |ft-f0| |ft-f0-h*J0*dx| Order --------------------------------------------------------- 0 1.00e-01 1.690e-01 8.400e-03 nan @@ -520,7 +520,7 @@ def check_derivative( except ImportError: matplotlib = False - print("{0!s} checkDerivative {1!s}".format("=" * 20, "=" * 20)) + print("{0!s} check_derivative {1!s}".format("=" * 20, "=" * 20)) print( "iter h |ft-f0| |ft-f0-h*J0*dx| Order\n{0!s}".format(("-" * 57)) ) diff --git a/discretize/tree_mesh.py b/discretize/tree_mesh.py index 422587d6c..4197335c9 100644 --- a/discretize/tree_mesh.py +++ b/discretize/tree_mesh.py @@ -799,7 +799,7 @@ def cell_gradient(self): # NOQA D102 iy[i_s[3]] = 0.0 Pafy = sp.diags(iy) - MfI = self.get_face_inner_product(invMat=True) + MfI = self.get_face_inner_product(invert_matrix=True) if self.dim == 2: Pi = sp.block_diag([Pafx, Pafy]) @@ -829,7 +829,7 @@ def cell_gradient_x(self): # NOQA D102 ix[i_s[1]] = 0.0 Pafx = sp.diags(ix) - MfI = self.get_face_inner_product(invMat=True) + MfI = self.get_face_inner_product(invert_matrix=True) MfIx = sp.diags(MfI.diagonal()[:nFx]) self._cell_gradient_x = ( @@ -851,7 +851,7 @@ def cell_gradient_y(self): # NOQA D102 iy[i_s[3]] = 0.0 Pafy = sp.diags(iy) - MfI = self.get_face_inner_product(invMat=True) + MfI = self.get_face_inner_product(invert_matrix=True) MfIy = sp.diags(MfI.diagonal()[nFx : nFx + nFy]) self._cell_gradient_y = ( @@ -875,7 +875,7 @@ def cell_gradient_z(self): # NOQA D102 iz[i_s[5]] = 0.0 Pafz = sp.diags(iz) - MfI = self.get_face_inner_product(invMat=True) + MfI = self.get_face_inner_product(invert_matrix=True) MfIz = sp.diags(MfI.diagonal()[nFx + nFy :]) self._cell_gradient_z = ( diff --git a/discretize/utils/mesh_utils.py b/discretize/utils/mesh_utils.py index 6b62c905e..34a6ea021 100644 --- a/discretize/utils/mesh_utils.py +++ b/discretize/utils/mesh_utils.py @@ -659,7 +659,7 @@ def refine_tree_xyz( Refine surface topography - >>> xx = mesh.vectorNx + >>> xx = mesh.nodes_x >>> yy = -3 * np.exp((xx ** 2) / 100 ** 2) + 50.0 >>> pts = np.c_[mkvc(xx), mkvc(yy)] >>> mesh = refine_tree_xyz( @@ -679,9 +679,9 @@ def refine_tree_xyz( >>> fig = plt.figure(figsize=(6, 6)) >>> ax = fig.add_subplot(111) - >>> mesh.plotGrid(ax=ax) - >>> ax.set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.hx)) - >>> ax.set_ybound(mesh.x0[1], mesh.x0[1] + np.sum(mesh.hy)) + >>> mesh.plot_grid(ax=ax) + >>> ax.set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.h[0])) + >>> ax.set_ybound(mesh.x0[1], mesh.x0[1] + np.sum(mesh.h[1])) >>> ax.set_title("QuadTree Mesh") >>> plt.show() """ From 4d97a2de27a49b9a1e0089fed409b9c5b1064ea6 Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Fri, 27 Jan 2023 16:12:42 -0800 Subject: [PATCH 08/16] Update examples and tutorials for deprecated functions. --- docs/content/inner_products.rst | 8 +-- examples/plot_cahn_hilliard.py | 6 +-- examples/plot_cyl_mirror.py | 6 +-- examples/plot_dc_resistivity.py | 14 ++--- examples/plot_image.py | 6 +-- examples/plot_quadtree_divergence.py | 4 +- examples/plot_quadtree_hanging.py | 2 +- examples/plot_streamThickness.py | 2 +- tutorials/inner_products/1_basic.py | 22 ++++---- .../inner_products/2_physical_properties.py | 52 +++++++++---------- tutorials/inner_products/3_calculus.py | 32 ++++++------ tutorials/inner_products/4_advanced.py | 28 +++++----- tutorials/mesh_generation/1_mesh_overview.py | 16 +++--- tutorials/mesh_generation/2_tensor_mesh.py | 28 +++++----- .../mesh_generation/3_cylindrical_mesh.py | 30 +++++------ tutorials/mesh_generation/4_tree_mesh.py | 32 ++++++------ tutorials/operators/1_averaging.py | 12 ++--- tutorials/operators/2_differential.py | 40 +++++++------- tutorials/pde/1_poisson.py | 12 ++--- tutorials/pde/2_advection_diffusion.py | 18 +++---- 20 files changed, 185 insertions(+), 185 deletions(-) diff --git a/docs/content/inner_products.rst b/docs/content/inner_products.rst index 6c3690d65..9b36d32c4 100644 --- a/docs/content/inner_products.rst +++ b/docs/content/inner_products.rst @@ -190,14 +190,14 @@ Which is nice and easy to invert if necessary, however, in the fully anisotropic import discretize import numpy as np import matplotlib.pyplot as plt - mesh = discretize.TensorMesh([10,50,3]) + mesh = discretize.TensorMesh([10,50,3])R m1 = np.random.rand(mesh.nC) m2 = np.random.rand(mesh.nC,3) m3 = np.random.rand(mesh.nC,6) M = list(range(3)) - M[0] = mesh.getFaceInnerProduct(m1) - M[1] = mesh.getFaceInnerProduct(m2) - M[2] = mesh.getFaceInnerProduct(m3) + M[0] = mesh.get_faceInnerProduct(m1) + M[1] = mesh.get_face_inner_product(m2) + M[2] = mesh.get_face_inner_product(m3) plt.figure(figsize=(13,5)) for i, lab in enumerate(['Isotropic','Anisotropic','Tensor']): plt.subplot(131 + i) diff --git a/examples/plot_cahn_hilliard.py b/examples/plot_cahn_hilliard.py index 8f3a79fd7..e24305b45 100644 --- a/examples/plot_cahn_hilliard.py +++ b/examples/plot_cahn_hilliard.py @@ -71,8 +71,8 @@ def run(plotIt=True, n=60): I = discretize.utils.speye(M.nC) # Operators - A = D * M.faceDiv * M.cellGrad - L = epsilon**2 * M.faceDiv * M.cellGrad + A = D * M.face_divergence * M.cell_gradient + L = epsilon**2 * M.face_divergence * M.cell_gradient duration = 75 elapsed = 0.0 @@ -105,7 +105,7 @@ def run(plotIt=True, n=60): axes = np.array(axes).flatten().tolist() for ii, ax in zip(np.linspace(0, len(PHIS) - 1, len(axes)), axes): ii = int(ii) - M.plotImage(PHIS[ii][1], ax=ax) + M.plot_image(PHIS[ii][1], ax=ax) ax.axis("off") ax.set_title("Elapsed Time: {0:4.1f}".format(PHIS[ii][0])) diff --git a/examples/plot_cyl_mirror.py b/examples/plot_cyl_mirror.py index 5a0c0424b..e498ddcf1 100644 --- a/examples/plot_cyl_mirror.py +++ b/examples/plot_cyl_mirror.py @@ -23,7 +23,7 @@ def run(plotIt=True): nc = np.ceil(2.5 * (-(sphere_z - sphere_radius)) / cs) # define a mesh - mesh = discretize.CylMesh([[(cs, nc)], 1, [(cs, nc)]], x0="00C") + mesh = discretize.CylindricalMesh([[(cs, nc)], 1, [(cs, nc)]], x0="00C") # Put the model on the mesh sigma = sig_air * np.ones(mesh.nC) # start with air cells @@ -42,12 +42,12 @@ def run(plotIt=True): fig, ax = plt.subplots(2, 1) # Set a nice colormap! plt.set_cmap(plt.get_cmap("viridis")) - plt.colorbar(mesh.plotImage(np.log10(sigma), ax=ax[0])[0], ax=ax[0]) + plt.colorbar(mesh.plot_image(np.log10(sigma), ax=ax[0])[0], ax=ax[0]) ax[0].set_title("mirror = False") ax[0].axis("equal") ax[0].set_xlim([-200.0, 200.0]) - plt.colorbar(mesh.plotImage(np.log10(sigma), ax=ax[1], mirror=True)[0], ax=ax[1]) + plt.colorbar(mesh.plot_image(np.log10(sigma), ax=ax[1], mirror=True)[0], ax=ax[1]) ax[1].set_title("mirror = True") ax[1].axis("equal") ax[1].set_xlim([-200.0, 200.0]) diff --git a/examples/plot_dc_resistivity.py b/examples/plot_dc_resistivity.py index e107c4934..3f227afed 100644 --- a/examples/plot_dc_resistivity.py +++ b/examples/plot_dc_resistivity.py @@ -14,17 +14,17 @@ def run(plotIt=True): # Step1: Generate Tensor and Curvilinear Mesh sz = [40, 40] tM = discretize.TensorMesh(sz) - rM = discretize.CurvilinearMesh(discretize.utils.exampleLrmGrid(sz, "rotate")) + rM = discretize.CurvilinearMesh(discretize.utils.example_curvilinear_grid(sz, "rotate")) # Step2: Direct Current (DC) operator def DCfun(mesh, pts): - D = mesh.faceDiv + D = mesh.face_divergence sigma = 1e-2 * np.ones(mesh.nC) - MsigI = mesh.getFaceInnerProduct(sigma, invProp=True, invMat=True) + MsigI = mesh.get_face_inner_product(sigma, invert_model=True, invert_matrix=True) A = -D * MsigI * D.T - A[-1, -1] /= mesh.vol[-1] # Remove null space + A[-1, -1] /= mesh.cell_volumes[-1] # Remove null space rhs = np.zeros(mesh.nC) - txind = discretize.utils.closestPoints(mesh, pts) + txind = discretize.utils.closest_points_index(mesh, pts) rhs[txind] = np.r_[1, -1] return A, rhs @@ -46,12 +46,12 @@ def DCfun(mesh, pts): fig, axes = plt.subplots(1, 2, figsize=(12 * 1.2, 4 * 1.2)) vmin, vmax = phitM.min(), phitM.max() - dat = tM.plotImage(phitM, ax=axes[0], clim=(vmin, vmax), grid=True) + dat = tM.plot_image(phitM, ax=axes[0], clim=(vmin, vmax), grid=True) cb0 = plt.colorbar(dat[0], ax=axes[0]) cb0.set_label("Voltage (V)") axes[0].set_title("TensorMesh") - dat = rM.plotImage(phirM, ax=axes[1], clim=(vmin, vmax), grid=True) + dat = rM.plot_image(phirM, ax=axes[1], clim=(vmin, vmax), grid=True) cb1 = plt.colorbar(dat[0], ax=axes[1]) cb1.set_label("Voltage (V)") axes[1].set_title("CurvilinearMesh") diff --git a/examples/plot_image.py b/examples/plot_image.py index 6d0302e94..d01d73868 100644 --- a/examples/plot_image.py +++ b/examples/plot_image.py @@ -34,7 +34,7 @@ def function(cell): O.refine(function) - P = M.getInterpolationMat(O.gridCC, "CC") + P = M.get_interpolation_matrix(O.gridCC, "CC") ov = P * v @@ -43,12 +43,12 @@ def function(cell): fig, axes = plt.subplots(1, 2, figsize=(10, 5)) - out = M.plotImage(v, grid=True, ax=axes[0]) + out = M.plot_image(v, grid=True, ax=axes[0]) cb = plt.colorbar(out[0], ax=axes[0]) cb.set_label("Random Field") axes[0].set_title("TensorMesh") - out = O.plotImage(ov, grid=True, ax=axes[1], clim=[0, 1]) + out = O.plot_image(ov, grid=True, ax=axes[1], clim=[0, 1]) cb = plt.colorbar(out[0], ax=axes[1]) cb.set_label("Random Field") axes[1].set_title("TreeMesh") diff --git a/examples/plot_quadtree_divergence.py b/examples/plot_quadtree_divergence.py index c11dea332..3e91c915d 100644 --- a/examples/plot_quadtree_divergence.py +++ b/examples/plot_quadtree_divergence.py @@ -23,7 +23,7 @@ def run(plotIt=True, n=60): if plotIt: fig, axes = plt.subplots(2, 1, figsize=(10, 10)) - M.plotGrid(centers=True, nodes=False, ax=axes[0]) + M.plot_grid(centers=True, nodes=False, ax=axes[0]) axes[0].axis("off") axes[0].set_title("Simple QuadTree Mesh") axes[0].set_xlim([-1, 17]) @@ -42,7 +42,7 @@ def run(plotIt=True, n=60): loc[0] + 0.2, loc[1] + 0.2, "{0:d}".format((ii + M.nFx)), color="m" ) - axes[1].spy(M.faceDiv) + axes[1].spy(M.face_divergence) axes[1].set_title("Face Divergence") axes[1].set_ylabel("Cell Number") axes[1].set_xlabel("Face Number") diff --git a/examples/plot_quadtree_hanging.py b/examples/plot_quadtree_hanging.py index 561247eb1..7bdb6c89e 100644 --- a/examples/plot_quadtree_hanging.py +++ b/examples/plot_quadtree_hanging.py @@ -26,7 +26,7 @@ def refine(cell): M.refine(refine) if plotIt: - M.plotGrid(nodes=True, centers=True, faces_x=True) + M.plot_grid(nodes=True, centers=True, faces_x=True) plt.legend( ( "Nodes", diff --git a/examples/plot_streamThickness.py b/examples/plot_streamThickness.py index 32c109d7a..75e06b186 100644 --- a/examples/plot_streamThickness.py +++ b/examples/plot_streamThickness.py @@ -71,7 +71,7 @@ stream_opts = {"color": "w", "density": 2.0} pcolor_opts = {"cmap": "viridis"} -dat = mesh.plotSlice( +dat = mesh.plot_slice( dataVec, ax=ax, normal="Z", diff --git a/tutorials/inner_products/1_basic.py b/tutorials/inner_products/1_basic.py index fad154b8a..bd86eec09 100644 --- a/tutorials/inner_products/1_basic.py +++ b/tutorials/inner_products/1_basic.py @@ -119,7 +119,7 @@ def fcn_gaussian(x, mu, sig): phi_n = fcn_gaussian(mesh.gridN, mu, sig) # Define inner-product matricies -Mc = sdiag(mesh.vol) # cell-centered +Mc = sdiag(mesh.cell_volumes) # cell-centered # Mn = mesh.getNodalInnerProduct() # on nodes (*functionality pending*) # Compute the inner product @@ -188,7 +188,7 @@ def fcn_y(xy, sig): vy = fcn_y(mesh.gridEy, sig) v = np.r_[vx, vy] -Me = mesh.getEdgeInnerProduct() # Edge inner product matrix +Me = mesh.get_edge_inner_product() # Edge inner product matrix ipe = np.dot(v, Me * v) @@ -197,7 +197,7 @@ def fcn_y(xy, sig): vy = fcn_y(mesh.gridFy, sig) v = np.r_[vx, vy] -Mf = mesh.getFaceInnerProduct() # Edge inner product matrix +Mf = mesh.get_face_inner_product() # Edge inner product matrix ipf = np.dot(v, Mf * v) @@ -207,7 +207,7 @@ def fcn_y(xy, sig): # Plot the vector function fig = plt.figure(figsize=(5, 5)) ax = fig.add_subplot(111) -mesh.plotImage( +mesh.plot_image( v, ax=ax, v_type="F", view="vec", stream_opts={"color": "w", "density": 1.0} ) ax.set_title("v at cell faces") @@ -241,20 +241,20 @@ def fcn_y(xy, sig): mesh = TensorMesh([h, h], "CC") # Cell centered for scalar quantities -Mc = sdiag(mesh.vol) -Mc_inv = sdiag(1 / mesh.vol) +Mc = sdiag(mesh.cell_volumes) +Mc_inv = sdiag(1 / mesh.cell_volumes) # Nodes for scalar quantities (*functionality pending*) # Mn = mesh.getNodalInnerProduct() -# Mn_inv = mesh.getNodalInnerProduct(invMat=True) +# Mn_inv = mesh.getNodalInnerProduct(invert_matrix=True) # Edges for vector quantities -Me = mesh.getEdgeInnerProduct() -Me_inv = mesh.getEdgeInnerProduct(invMat=True) +Me = mesh.get_edge_inner_product() +Me_inv = mesh.get_edge_inner_product(invert_matrix=True) # Faces for vector quantities -Mf = mesh.getFaceInnerProduct() -Mf_inv = mesh.getFaceInnerProduct(invMat=True) +Mf = mesh.get_face_inner_product() +Mf_inv = mesh.get_face_inner_product(invert_matrix=True) # Generate some random vectors phi_c = np.random.rand(mesh.nC) diff --git a/tutorials/inner_products/2_physical_properties.py b/tutorials/inner_products/2_physical_properties.py index 6cc6cc40d..531e8b077 100644 --- a/tutorials/inner_products/2_physical_properties.py +++ b/tutorials/inner_products/2_physical_properties.py @@ -106,14 +106,14 @@ # Isotropic case sig = sig1 * np.ones((1, 1)) sig_tensor_1 = np.diag(sig1 * np.ones(3)) -Me1 = mesh.getEdgeInnerProduct(sig) # Edges inner product matrix -Mf1 = mesh.getFaceInnerProduct(sig) # Faces inner product matrix +Me1 = mesh.get_edge_inner_product(sig) # Edges inner product matrix +Mf1 = mesh.get_face_inner_product(sig) # Faces inner product matrix # Diagonal anisotropic sig = np.c_[sig1, sig2, sig3] sig_tensor_2 = np.diag(np.array([sig1, sig2, sig3])) -Me2 = mesh.getEdgeInnerProduct(sig) -Mf2 = mesh.getFaceInnerProduct(sig) +Me2 = mesh.get_edge_inner_product(sig) +Mf2 = mesh.get_face_inner_product(sig) # Full anisotropic sig = np.c_[sig1, sig2, sig3, sig4, sig5, sig6] @@ -121,8 +121,8 @@ sig_tensor_3[(0, 1), (1, 0)] = sig4 sig_tensor_3[(0, 2), (2, 0)] = sig5 sig_tensor_3[(1, 2), (2, 1)] = sig6 -Me3 = mesh.getEdgeInnerProduct(sig) -Mf3 = mesh.getFaceInnerProduct(sig) +Me3 = mesh.get_edge_inner_product(sig) +Mf3 = mesh.get_face_inner_product(sig) # Plotting matrix entries fig = plt.figure(figsize=(12, 12)) @@ -182,18 +182,18 @@ # Isotropic case: (nC, ) numpy array sig = np.random.rand(mesh.nC) # sig for each cell -Me1 = mesh.getEdgeInnerProduct(sig) # Edges inner product matrix -Mf1 = mesh.getFaceInnerProduct(sig) # Faces inner product matrix +Me1 = mesh.get_edge_inner_product(sig) # Edges inner product matrix +Mf1 = mesh.get_face_inner_product(sig) # Faces inner product matrix # Linear case: (nC, dim) numpy array sig = np.random.rand(mesh.nC, mesh.dim) -Me2 = mesh.getEdgeInnerProduct(sig) -Mf2 = mesh.getFaceInnerProduct(sig) +Me2 = mesh.get_edge_inner_product(sig) +Mf2 = mesh.get_face_inner_product(sig) # Anisotropic case: (nC, 3) for 2D and (nC, 6) for 3D sig = np.random.rand(mesh.nC, 6) -Me3 = mesh.getEdgeInnerProduct(sig) -Mf3 = mesh.getFaceInnerProduct(sig) +Me3 = mesh.get_edge_inner_product(sig) +Mf3 = mesh.get_face_inner_product(sig) # Properties of inner product matricies print("\n FACE INNER PRODUCT MATRIX") @@ -217,7 +217,7 @@ # # The final discretized system using the finite volume method may contain # the inverse of the inner-product matrix. Here we show how to call this -# using the *invMat* keyword argument. +# using the *invert_matrix* keyword argument. # # For the isotropic and diagonally anisotropic cases, the inner product matrix # is diagonal. As a result, its inverse can be easily formed. For the full @@ -236,18 +236,18 @@ # Isotropic case: (nC, ) numpy array sig = np.random.rand(mesh.nC) -Me1_inv = mesh.getEdgeInnerProduct(sig, invMat=True) -Mf1_inv = mesh.getFaceInnerProduct(sig, invMat=True) +Me1_inv = mesh.get_edge_inner_product(sig, invert_matrix=True) +Mf1_inv = mesh.get_face_inner_product(sig, invert_matrix=True) # Diagonal anisotropic: (nC, dim) numpy array sig = np.random.rand(mesh.nC, mesh.dim) -Me2_inv = mesh.getEdgeInnerProduct(sig, invMat=True) -Mf2_inv = mesh.getFaceInnerProduct(sig, invMat=True) +Me2_inv = mesh.get_edge_inner_product(sig, invert_matrix=True) +Mf2_inv = mesh.get_face_inner_product(sig, invert_matrix=True) # Full anisotropic: (nC, 3) for 2D and (nC, 6) for 3D sig = np.random.rand(mesh.nC, 6) -Me3 = mesh.getEdgeInnerProduct(sig) -Mf3 = mesh.getFaceInnerProduct(sig) +Me3 = mesh.get_edge_inner_product(sig) +Mf3 = mesh.get_face_inner_product(sig) ########################################################################### @@ -256,7 +256,7 @@ # # At times, the constitutive relation may be defined by the reciprocal of # a parameter (:math:`\rho`). Here we demonstrate how inner product matricies -# can be formed using the keyword argument *invProp*. We will do this for a +# can be formed using the keyword argument *invert_model*. We will do this for a # single cell and plot the matrix elements. We can easily extend this to # a mesh comprised of many cells. # @@ -322,18 +322,18 @@ # Isotropic case rho = rho1 * np.ones((1, 1)) -Me1 = mesh.getEdgeInnerProduct(rho, invProp=True) # Edges inner product matrix -Mf1 = mesh.getFaceInnerProduct(rho, invProp=True) # Faces inner product matrix +Me1 = mesh.get_edge_inner_product(rho, invert_model=True) # Edges inner product matrix +Mf1 = mesh.get_face_inner_product(rho, invert_model=True) # Faces inner product matrix # Diagonal anisotropic case rho = np.c_[rho1, rho2, rho3] -Me2 = mesh.getEdgeInnerProduct(rho, invProp=True) -Mf2 = mesh.getFaceInnerProduct(rho, invProp=True) +Me2 = mesh.get_edge_inner_product(rho, invert_model=True) +Mf2 = mesh.get_face_inner_product(rho, invert_model=True) # Full anisotropic case rho = np.c_[rho1, rho2, rho3, rho4, rho5, rho6] -Me3 = mesh.getEdgeInnerProduct(rho, invProp=True) -Mf3 = mesh.getFaceInnerProduct(rho, invProp=True) +Me3 = mesh.get_edge_inner_product(rho, invert_model=True) +Mf3 = mesh.get_face_inner_product(rho, invert_model=True) # Plotting matrix entries fig = plt.figure(figsize=(14, 9)) diff --git a/tutorials/inner_products/3_calculus.py b/tutorials/inner_products/3_calculus.py index c52eb7ac5..cf3ff621a 100644 --- a/tutorials/inner_products/3_calculus.py +++ b/tutorials/inner_products/3_calculus.py @@ -75,13 +75,13 @@ mesh = TensorMesh([h, h, h]) # Items required to perform u.T*(Me*Gn*phi) -Me = mesh.getEdgeInnerProduct() # Basic inner product matrix (edges) -Gn = mesh.nodalGrad # Nodes to edges gradient +Me = mesh.get_edge_inner_product() # Basic inner product matrix (edges) +Gn = mesh.nodal_gradient # Nodes to edges gradient # Items required to perform u.T*(Mf*Gc*phi) -Mf = mesh.getFaceInnerProduct() # Basic inner product matrix (faces) -mesh.setCellGradBC(["neumann", "dirichlet", "neumann"]) # Set boundary conditions -Gc = mesh.cellGrad # Cells to faces gradient +Mf = mesh.get_face_inner_product() # Basic inner product matrix (faces) +mesh.set_cell_gradient_BC(["neumann", "dirichlet", "neumann"]) # Set boundary conditions +Gc = mesh.cell_gradient # Cells to faces gradient # Plot Sparse Representation fig = plt.figure(figsize=(5, 6)) @@ -120,8 +120,8 @@ mesh = TensorMesh([h, h, h]) # Items required to perform psi.T*(Mc*D*v) -Mc = sdiag(mesh.vol) # Basic inner product matrix (centers) -D = mesh.faceDiv # Faces to centers divergence +Mc = sdiag(mesh.cell_volumes) # Basic inner product matrix (centers) +D = mesh.face_divergence # Faces to centers divergence # Plot sparse representation fig = plt.figure(figsize=(8, 5)) @@ -173,12 +173,12 @@ mesh = TensorMesh([h, h, h]) # Items required to perform u.T*(Mf*Ce*v) -Mf = mesh.getFaceInnerProduct() # Basic inner product matrix (faces) -Ce = mesh.edgeCurl # Edges to faces curl +Mf = mesh.get_face_inner_product() # Basic inner product matrix (faces) +Ce = mesh.edge_curl # Edges to faces curl # Items required to perform u.T*(Me*Cf*v) -Me = mesh.getEdgeInnerProduct() # Basic inner product matrix (edges) -Cf = mesh.edgeCurl.T # Faces to edges curl (assumes Dirichlet) +Me = mesh.get_edge_inner_product() # Basic inner product matrix (edges) +Cf = mesh.edge_curl.T # Faces to edges curl (assumes Dirichlet) # Plot Sparse Representation fig = plt.figure(figsize=(9, 5)) @@ -241,13 +241,13 @@ mesh = TensorMesh([h, h, h]) # Items required to perform psi.T*(Gn.T*Me*Gn*phi) -Me = mesh.getEdgeInnerProduct() # Basic inner product matrix (edges) -Gn = mesh.nodalGrad # Nodes to edges gradient +Me = mesh.get_edge_inner_product() # Basic inner product matrix (edges) +Gn = mesh.nodal_gradient # Nodes to edges gradient # Items required to perform psi.T*(Gc.T*Mf*Gc*phi) -Mf = mesh.getFaceInnerProduct() # Basic inner product matrix (faces) -mesh.setCellGradBC(["dirichlet", "dirichlet", "dirichlet"]) -Gc = mesh.cellGrad # Centers to faces gradient +Mf = mesh.get_face_inner_product() # Basic inner product matrix (faces) +mesh.set_cell_gradient_BC(["dirichlet", "dirichlet", "dirichlet"]) +Gc = mesh.cell_gradient # Centers to faces gradient # Plot Sparse Representation fig = plt.figure(figsize=(9, 4)) diff --git a/tutorials/inner_products/4_advanced.py b/tutorials/inner_products/4_advanced.py index 03075ecd5..7b98c7513 100644 --- a/tutorials/inner_products/4_advanced.py +++ b/tutorials/inner_products/4_advanced.py @@ -78,18 +78,18 @@ Sig = np.random.rand(mesh.nC, 6) # anisotropic # Inner product matricies -Mc = sdiag(mesh.vol * sig) # Inner product matrix (centers) +Mc = sdiag(mesh.cell_volumes * sig) # Inner product matrix (centers) # Mn = mesh.getNodalInnerProduct(sig) # Inner product matrix (nodes) (*functionality pending*) -Me = mesh.getEdgeInnerProduct(sig) # Inner product matrix (edges) -Mf = mesh.getFaceInnerProduct(sig) # Inner product matrix for tensor (faces) +Me = mesh.get_edge_inner_product(sig) # Inner product matrix (edges) +Mf = mesh.get_face_inner_product(sig) # Inner product matrix for tensor (faces) # Differential operators -Gne = mesh.nodalGrad # Nodes to edges gradient -mesh.setCellGradBC(["neumann", "dirichlet", "neumann"]) # Set boundary conditions -Gcf = mesh.cellGrad # Cells to faces gradient -D = mesh.faceDiv # Faces to centers divergence -Cef = mesh.edgeCurl # Edges to faces curl -Cfe = mesh.edgeCurl.T # Faces to edges curl +Gne = mesh.nodal_gradient # Nodes to edges gradient +mesh.set_cell_gradient_BC(["neumann", "dirichlet", "neumann"]) # Set boundary conditions +Gcf = mesh.cell_gradient # Cells to faces gradient +D = mesh.face_divergence # Faces to centers divergence +Cef = mesh.edge_curl # Edges to faces curl +Cfe = mesh.edge_curl.T # Faces to edges curl # EXAMPLE: (u, sig*Curl*v) fig = plt.figure(figsize=(9, 5)) @@ -98,7 +98,7 @@ ax1.spy(Mf * Cef, markersize=0.5) ax1.set_title("Me(sig)*Cef (Isotropic)", pad=10) -Mf_tensor = mesh.getFaceInnerProduct(Sig) # inner product matrix for tensor +Mf_tensor = mesh.get_face_inner_product(Sig) # inner product matrix for tensor ax2 = fig.add_subplot(122) ax2.spy(Mf_tensor * Cef, markersize=0.5) ax2.set_title("Me(sig)*Cef (Anisotropic)", pad=10) @@ -154,12 +154,12 @@ mesh = TensorMesh([h, h, h]) # Inner product matricies -Mc = sdiag(mesh.vol * sig) # Inner product matrix (centers) +Mc = sdiag(mesh.cell_volumes * sig) # Inner product matrix (centers) # Differential operators -mesh.setCellGradBC(["neumann", "dirichlet", "neumann"]) # Set boundary conditions -Gcf = mesh.cellGrad # Cells to faces gradient -Dfc = mesh.faceDiv # Faces to centers divergence +mesh.set_cell_gradient_BC(["neumann", "dirichlet", "neumann"]) # Set boundary conditions +Gcf = mesh.cell_gradient # Cells to faces gradient +Dfc = mesh.face_divergence # Faces to centers divergence # Averaging and summing matrix Afc = mesh.dim * mesh.aveF2CC diff --git a/tutorials/mesh_generation/1_mesh_overview.py b/tutorials/mesh_generation/1_mesh_overview.py index e183bacfb..c6d918533 100644 --- a/tutorials/mesh_generation/1_mesh_overview.py +++ b/tutorials/mesh_generation/1_mesh_overview.py @@ -17,7 +17,7 @@ # # The three main types of meshes in discretize are # -# - **Tensor meshes** (:class:`discretize.TensorMesh`); which includes **cylindrical meshes** (:class:`discretize.CylMesh`) +# - **Tensor meshes** (:class:`discretize.TensorMesh`); which includes **cylindrical meshes** (:class:`discretize.CylindricalMesh`) # # - **Tree meshes** (:class:`discretize.TreeMesh`): also referred to as QuadTree or OcTree meshes # @@ -46,18 +46,18 @@ def refine(cell): # create a curvilinear mesh curvi_mesh = discretize.CurvilinearMesh( - discretize.utils.exampleLrmGrid([ncx, ncy], "rotate") + discretize.utils.example_curvilinear_grid([ncx, ncy], "rotate") ) # Plot fig, axes = plt.subplots(1, 3, figsize=(14.5, 4)) -tensor_mesh.plotGrid(ax=axes[0]) +tensor_mesh.plot_grid(ax=axes[0]) axes[0].set_title("TensorMesh") -tree_mesh.plotGrid(ax=axes[1]) +tree_mesh.plot_grid(ax=axes[1]) axes[1].set_title("TreeMesh") -curvi_mesh.plotGrid(ax=axes[2]) +curvi_mesh.plot_grid(ax=axes[2]) axes[2].set_title("CurvilinearMesh") ############################################################################### @@ -81,15 +81,15 @@ def refine(cell): # Plot fig, axes2 = plt.subplots(1, 3, figsize=(14.5, 5)) -tensor_mesh2.plotGrid(ax=axes2[0], nodes=True, centers=True) +tensor_mesh2.plot_grid(ax=axes2[0], nodes=True, centers=True) axes2[0].legend(("Nodes", "Centers")) axes2[0].set_title("Nodes and cell centers") -tensor_mesh2.plotGrid(ax=axes2[1], edges=True) +tensor_mesh2.plot_grid(ax=axes2[1], edges=True) axes2[1].legend(("X-edges", "Y-edges")) axes2[1].set_title("Cell edges") -tensor_mesh2.plotGrid(ax=axes2[2], faces=True) +tensor_mesh2.plot_grid(ax=axes2[2], faces=True) axes2[2].legend(("X-faces", "Y-faces")) axes2[2].set_title("Cell faces") diff --git a/tutorials/mesh_generation/2_tensor_mesh.py b/tutorials/mesh_generation/2_tensor_mesh.py index 18667d86b..5c4bdd29a 100644 --- a/tutorials/mesh_generation/2_tensor_mesh.py +++ b/tutorials/mesh_generation/2_tensor_mesh.py @@ -48,7 +48,7 @@ mesh = TensorMesh([hx, hy], x0=[x0, y0]) -mesh.plotGrid() +mesh.plot_grid() ############################################### @@ -81,12 +81,12 @@ # relative to the origin mesh = TensorMesh([hx, hy], x0="CN") -# We can apply the plotGrid method and output to a specified axes object +# We can apply the plot_grid method and output to a specified axes object fig = plt.figure(figsize=(6, 6)) ax = fig.add_subplot(111) -mesh.plotGrid(ax=ax) -ax.set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.hx)) -ax.set_ybound(mesh.x0[1], mesh.x0[1] + np.sum(mesh.hy)) +mesh.plot_grid(ax=ax) +ax.set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.h[0])) +ax.set_ybound(mesh.x0[1], mesh.x0[1] + np.sum(mesh.h[1])) ax.set_title("Tensor Mesh") ############################################### @@ -121,16 +121,16 @@ cc = mesh.gridCC # A boolean array specifying which cells lie on the boundary -bInd = mesh.cellBoundaryInd +bInd = mesh.cell_boundary_indices # Plot the cell areas (2D "volume") -s = mesh.vol +s = mesh.cell_volumes fig = plt.figure(figsize=(6, 6)) ax = fig.add_subplot(111) -mesh.plotImage(s, grid=True, ax=ax) -ax.set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.hx)) -ax.set_ybound(mesh.x0[1], mesh.x0[1] + np.sum(mesh.hy)) +mesh.plot_image(s, grid=True, ax=ax) +ax.set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.h[0])) +ax.set_ybound(mesh.x0[1], mesh.x0[1] + np.sum(mesh.h[1])) ax.set_title("Cell Areas") @@ -160,19 +160,19 @@ cc = mesh.gridCC # A boolean array specifying which cells lie on the boundary -bInd = mesh.cellBoundaryInd +bInd = mesh.cell_boundary_indices # The cell volumes -v = mesh.vol +v = mesh.cell_volumes # Plot all cells volumes or plot cell volumes for a particular horizontal slice fig = plt.figure(figsize=(9, 4)) ax1 = fig.add_subplot(121) ax2 = fig.add_subplot(122) -mesh.plotImage(np.log10(v), grid=True, ax=ax1) +mesh.plot_image(np.log10(v), grid=True, ax=ax1) ax1.set_title("All Cell Log-Volumes") -cplot = mesh.plotSlice(np.log10(v), grid=True, ax=ax2, normal="Z", ind=2) +cplot = mesh.plot_slice(np.log10(v), grid=True, ax=ax2, normal="Z", ind=2) cplot[0].set_clim(np.min(np.log10(v)), np.max(np.log10(v))) ax2.set_title("Cell Log-Volumes #2") diff --git a/tutorials/mesh_generation/3_cylindrical_mesh.py b/tutorials/mesh_generation/3_cylindrical_mesh.py index 410e79605..f6a4ccae8 100644 --- a/tutorials/mesh_generation/3_cylindrical_mesh.py +++ b/tutorials/mesh_generation/3_cylindrical_mesh.py @@ -2,7 +2,7 @@ Cylindrical meshes ================== -Cylindrical meshes (:class:`~discretize.CylMesh`) are defined in terms of *r* +Cylindrical meshes (:class:`~discretize.CylindricalMesh`) are defined in terms of *r* (radial position), *z* (vertical position) and *phi* (azimuthal position). They are a child class of the tensor mesh class. Cylindrical meshes are useful in solving differential equations that possess rotational symmetry. Here we @@ -24,7 +24,7 @@ # Here we import the packages required for this tutorial. # -from discretize import CylMesh +from discretize import CylindricalMesh import matplotlib.pyplot as plt import numpy as np @@ -55,9 +55,9 @@ y0 = 0.0 z0 = -150.0 -mesh = CylMesh([hr, hp, hz], x0=[x0, y0, z0]) +mesh = CylindricalMesh([hr, hp, hz], x0=[x0, y0, z0]) -mesh.plotGrid() +mesh.plot_grid() ############################################### @@ -89,16 +89,16 @@ hz = [(dz, npad_z, -exp_z), (dz, ncz), (dz, npad_z, exp_z)] # We can use flags 'C', '0' and 'N' to define the xyz position of the mesh. -mesh = CylMesh([hr, hp, hz], x0="00C") +mesh = CylindricalMesh([hr, hp, hz], x0="00C") -# We can apply the plotGrid method and change the axis properties -ax = mesh.plotGrid() +# We can apply the plot_grid method and change the axis properties +ax = mesh.plot_grid() ax[0].set_title("Discretization in phi") ax[1].set_title("Discretization in r and z") ax[1].set_xlabel("r") -ax[1].set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.hx)) -ax[1].set_ybound(mesh.x0[2], mesh.x0[2] + np.sum(mesh.hz)) +ax[1].set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.h[0])) +ax[1].set_ybound(mesh.x0[2], mesh.x0[2] + np.sum(mesh.h[2])) # The bottom end of the vertical axis of rotational symmetry x0 = mesh.x0 @@ -110,7 +110,7 @@ cc = mesh.gridCC # The cell volumes -v = mesh.vol +v = mesh.cell_volumes ############################################### # Cylindrical Mesh for Rotational Symmetry @@ -142,7 +142,7 @@ hz = [(dz, npad_z, -exp_z), (dz, ncz), (dz, npad_z, exp_z)] # A value of 1 is used to define the discretization in phi for this case. -mesh = CylMesh([hr, 1, hz], x0="00C") +mesh = CylindricalMesh([hr, 1, hz], x0="00C") # The bottom end of the vertical axis of rotational symmetry x0 = mesh.x0 @@ -154,14 +154,14 @@ cc = mesh.gridCC # Plot the cell volumes. -v = mesh.vol +v = mesh.cell_volumes fig = plt.figure(figsize=(6, 4)) ax = fig.add_subplot(111) -mesh.plotImage(np.log10(v), grid=True, ax=ax) +mesh.plot_image(np.log10(v), grid=True, ax=ax) ax.set_xlabel("r") -ax.set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.hx)) -ax.set_ybound(mesh.x0[2], mesh.x0[2] + np.sum(mesh.hz)) +ax.set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.h[0])) +ax.set_ybound(mesh.x0[2], mesh.x0[2] + np.sum(mesh.h[2])) ax.set_title("Cell Log-Volumes") ############################################################################## diff --git a/tutorials/mesh_generation/4_tree_mesh.py b/tutorials/mesh_generation/4_tree_mesh.py index fd5d007ec..094aff933 100644 --- a/tutorials/mesh_generation/4_tree_mesh.py +++ b/tutorials/mesh_generation/4_tree_mesh.py @@ -65,7 +65,7 @@ padding = [[0, 2], [0, 2]] mesh.refine_bounding_box(xy, level=-1, padding_cells_by_level=padding) -mesh.plotGrid(show_it=True) +mesh.plot_grid(show_it=True) ############################################### @@ -98,7 +98,7 @@ mesh = TreeMesh([hx, hy], x0="CC") # Refine surface topography -xx = mesh.vectorNx +xx = mesh.nodes_x yy = -3 * np.exp((xx**2) / 100**2) + 50.0 pts = np.c_[mkvc(xx), mkvc(yy)] padding = [[0, 2], [0, 2]] @@ -112,12 +112,12 @@ mesh.finalize() -# We can apply the plotGrid method and output to a specified axes object +# We can apply the plot_grid method and output to a specified axes object fig = plt.figure(figsize=(6, 6)) ax = fig.add_subplot(111) -mesh.plotGrid(ax=ax) -ax.set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.hx)) -ax.set_ybound(mesh.x0[1], mesh.x0[1] + np.sum(mesh.hy)) +mesh.plot_grid(ax=ax) +ax.set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.h[0])) +ax.set_ybound(mesh.x0[1], mesh.x0[1] + np.sum(mesh.h[1])) ax.set_title("QuadTree Mesh") #################################################### @@ -144,7 +144,7 @@ mesh = TreeMesh([hx, hy], x0="CC") # Refine surface topography -xx = mesh.vectorNx +xx = mesh.nodes_x yy = -3 * np.exp((xx**2) / 100**2) + 50.0 pts = np.c_[mkvc(xx), mkvc(yy)] padding = [[0, 2], [0, 2]] @@ -168,16 +168,16 @@ cc = mesh.gridCC # A boolean array specifying which cells lie on the boundary -bInd = mesh.cellBoundaryInd +bInd = mesh.cell_boundary_indices # The cell areas (2D "volume") -s = mesh.vol +s = mesh.cell_volumes fig = plt.figure(figsize=(6, 6)) ax = fig.add_subplot(111) -mesh.plotImage(np.log10(s), grid=True, ax=ax) -ax.set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.hx)) -ax.set_ybound(mesh.x0[1], mesh.x0[1] + np.sum(mesh.hy)) +mesh.plot_image(np.log10(s), grid=True, ax=ax) +ax.set_xbound(mesh.x0[0], mesh.x0[0] + np.sum(mesh.h[0])) +ax.set_ybound(mesh.x0[1], mesh.x0[1] + np.sum(mesh.h[1])) ax.set_title("Log of Cell Areas") ############################################### @@ -208,7 +208,7 @@ mesh = TreeMesh([hx, hy, hz], x0="CCC") # Refine surface topography -[xx, yy] = np.meshgrid(mesh.vectorNx, mesh.vectorNy) +[xx, yy] = np.meshgrid(mesh.nodes_x, mesh.nodes_y) zz = -3 * np.exp((xx**2 + yy**2) / 100**2) + 50.0 pts = np.c_[mkvc(xx), mkvc(yy), mkvc(zz)] padding = [[0, 0, 2], [0, 0, 2]] @@ -230,12 +230,12 @@ cc = mesh.gridCC # A boolean array specifying which cells lie on the boundary -bInd = mesh.cellBoundaryInd +bInd = mesh.cell_boundary_indices # Cell volumes -v = mesh.vol +v = mesh.cell_volumes fig = plt.figure(figsize=(6, 6)) ax = fig.add_subplot(111) -mesh.plotSlice(np.log10(v), normal="Y", ax=ax, ind=int(mesh.hy.size / 2), grid=True) +mesh.plot_slice(np.log10(v), normal="Y", ax=ax, ind=int(mesh.h[1].size / 2), grid=True) ax.set_title("Cell Log-Volumes at Y = 0 m") diff --git a/tutorials/operators/1_averaging.py b/tutorials/operators/1_averaging.py index 5d4b26a2d..8876bda9c 100644 --- a/tutorials/operators/1_averaging.py +++ b/tutorials/operators/1_averaging.py @@ -47,8 +47,8 @@ mesh = TensorMesh([h], "C") # Get node and cell center locations -x_nodes = mesh.vectorNx -x_centers = mesh.vectorCCx +x_nodes = mesh.nodes_x +x_centers = mesh.cell_centers_x # Define a continuous function @@ -175,22 +175,22 @@ def fun(x): fig = plt.figure(figsize=(10, 10)) ax1 = fig.add_subplot(221) -mesh.plotImage(v, ax=ax1) +mesh.plot_image(v, ax=ax1) ax1.set_title("Variable at cell centers") # Apply cell centers to faces averaging ax2 = fig.add_subplot(222) -mesh.plotImage(A2 * v, ax=ax2, v_type="F") +mesh.plot_image(A2 * v, ax=ax2, v_type="F") ax2.set_title("Cell centers to faces") # Use the transpose to go from cell centers to nodes ax3 = fig.add_subplot(223) -mesh.plotImage(A3.T * v, ax=ax3, v_type="N") +mesh.plot_image(A3.T * v, ax=ax3, v_type="N") ax3.set_title("Cell centers to nodes using transpose") # Use the transpose to go from cell centers to faces ax4 = fig.add_subplot(224) -mesh.plotImage(A4.T * v, ax=ax4, v_type="F") +mesh.plot_image(A4.T * v, ax=ax4, v_type="F") ax4.set_title("Cell centers to faces using transpose") fig.show() diff --git a/tutorials/operators/2_differential.py b/tutorials/operators/2_differential.py index 3d387576a..32d9a3ad0 100644 --- a/tutorials/operators/2_differential.py +++ b/tutorials/operators/2_differential.py @@ -52,15 +52,15 @@ class (*Tensor mesh*, *Tree mesh*, *Curvilinear mesh*), the set of numerical mesh = TensorMesh([h], "C") # Get node and cell center locations -x_nodes = mesh.vectorNx -x_centers = mesh.vectorCCx +x_nodes = mesh.nodes_x +x_centers = mesh.cell_centers_x # Compute function on nodes and derivative at cell centers v = np.exp(-(x_nodes**2) / 4**2) dvdx = -(2 * x_centers / 4**2) * np.exp(-(x_centers**2) / 4**2) # Derivative in x (gradient in 1D) from nodes to cell centers -G = mesh.nodalGrad +G = mesh.nodal_gradient dvdx_approx = G * v # Compare @@ -102,9 +102,9 @@ class (*Tensor mesh*, *Tree mesh*, *Curvilinear mesh*), the set of numerical mesh = TensorMesh([h, h, h], "CCC") # Get differential operators -GRAD = mesh.nodalGrad # Gradient from nodes to edges -DIV = mesh.faceDiv # Divergence from faces to cell centers -CURL = mesh.edgeCurl # Curl edges to cell centers +GRAD = mesh.nodal_gradient # Gradient from nodes to edges +DIV = mesh.face_divergence # Divergence from faces to cell centers +CURL = mesh.edge_curl # Curl edges to cell centers fig = plt.figure(figsize=(9, 8)) @@ -156,9 +156,9 @@ class (*Tensor mesh*, *Tree mesh*, *Curvilinear mesh*), the set of numerical mesh = TensorMesh([h, h], "CC") # Get differential operators -GRAD = mesh.nodalGrad # Gradient from nodes to edges -DIV = mesh.faceDiv # Divergence from faces to cell centers -CURL = mesh.edgeCurl # Curl edges to cell centers (goes to faces in 3D) +GRAD = mesh.nodal_gradient # Gradient from nodes to edges +DIV = mesh.face_divergence # Divergence from faces to cell centers +CURL = mesh.edge_curl # Curl edges to cell centers (goes to faces in 3D) # Evaluate gradient of a scalar function nodes = mesh.gridN @@ -199,11 +199,11 @@ class (*Tensor mesh*, *Tree mesh*, *Curvilinear mesh*), the set of numerical fig = plt.figure(figsize=(10, 5)) ax1 = fig.add_subplot(121) -mesh.plotImage(u, ax=ax1, v_type="N") +mesh.plot_image(u, ax=ax1, v_type="N") ax1.set_title("u at cell centers") ax2 = fig.add_subplot(122) -mesh.plotImage( +mesh.plot_image( grad_u, ax=ax2, v_type="E", view="vec", stream_opts={"color": "w", "density": 1.0} ) ax2.set_title("gradient of u on edges") @@ -214,13 +214,13 @@ class (*Tensor mesh*, *Tree mesh*, *Curvilinear mesh*), the set of numerical fig = plt.figure(figsize=(10, 5)) ax1 = fig.add_subplot(121) -mesh.plotImage( +mesh.plot_image( v, ax=ax1, v_type="F", view="vec", stream_opts={"color": "w", "density": 1.0} ) ax1.set_title("v at cell faces") ax2 = fig.add_subplot(122) -mesh.plotImage(div_v, ax=ax2) +mesh.plot_image(div_v, ax=ax2) ax2.set_title("divergence of v at cell centers") fig.show() @@ -229,13 +229,13 @@ class (*Tensor mesh*, *Tree mesh*, *Curvilinear mesh*), the set of numerical fig = plt.figure(figsize=(10, 5)) ax1 = fig.add_subplot(121) -mesh.plotImage( +mesh.plot_image( w, ax=ax1, v_type="E", view="vec", stream_opts={"color": "w", "density": 1.0} ) ax1.set_title("w at cell edges") ax2 = fig.add_subplot(122) -mesh.plotImage(curl_w, ax=ax2) +mesh.plot_image(curl_w, ax=ax2) ax2.set_title("curl of w at cell centers") fig.show() @@ -261,7 +261,7 @@ class (*Tensor mesh*, *Tree mesh*, *Curvilinear mesh*), the set of numerical ax1 = fig.add_subplot(211) -mesh.plotGrid(centers=True, nodes=False, ax=ax1) +mesh.plot_grid(centers=True, nodes=False, ax=ax1) ax1.axis("off") ax1.set_title("Simple QuadTree Mesh") ax1.set_xlim([-1, 17]) @@ -279,7 +279,7 @@ class (*Tensor mesh*, *Tree mesh*, *Curvilinear mesh*), the set of numerical ax1.text(loc[0] + 0.2, loc[1] + 0.2, "{0:d}".format((ii + mesh.nFx)), color="m") ax2 = fig.add_subplot(212) -ax2.spy(mesh.faceDiv) +ax2.spy(mesh.face_divergence) ax2.set_title("Face Divergence") ax2.set_ylabel("Cell Number") ax2.set_xlabel("Face Number") @@ -310,9 +310,9 @@ class (*Tensor mesh*, *Tree mesh*, *Curvilinear mesh*), the set of numerical mesh = TensorMesh([h, h, h], "CCC") # Get operators -GRAD = mesh.nodalGrad # nodes to edges -DIV = mesh.faceDiv # faces to centers -CURL = mesh.edgeCurl # edges to faces +GRAD = mesh.nodal_gradient # nodes to edges +DIV = mesh.face_divergence # faces to centers +CURL = mesh.edge_curl # edges to faces # Plot fig = plt.figure(figsize=(11, 7)) diff --git a/tutorials/pde/1_poisson.py b/tutorials/pde/1_poisson.py index b83c36547..fdfe3ed20 100644 --- a/tutorials/pde/1_poisson.py +++ b/tutorials/pde/1_poisson.py @@ -107,9 +107,9 @@ mesh = TensorMesh([h, h], "CC") # Create system -DIV = mesh.faceDiv # Faces to cell centers divergence -Mf_inv = mesh.getFaceInnerProduct(invMat=True) -Mc = sdiag(mesh.vol) +DIV = mesh.face_divergence # Faces to cell centers divergence +Mf_inv = mesh.get_face_inner_product(invert_matrix=True) +Mc = sdiag(mesh.cell_volumes) A = Mc * DIV * Mf_inv * DIV.T * Mc # Define RHS (charge distributions at cell centers) @@ -132,15 +132,15 @@ fig = plt.figure(figsize=(14, 4)) ax1 = fig.add_subplot(131) -mesh.plotImage(rho, v_type="CC", ax=ax1) +mesh.plot_image(rho, v_type="CC", ax=ax1) ax1.set_title("Charge Density") ax2 = fig.add_subplot(132) -mesh.plotImage(phi, v_type="CC", ax=ax2) +mesh.plot_image(phi, v_type="CC", ax=ax2) ax2.set_title("Electric Potential") ax3 = fig.add_subplot(133) -mesh.plotImage( +mesh.plot_image( E, ax=ax3, v_type="F", view="vec", stream_opts={"color": "w", "density": 1.0} ) ax3.set_title("Electric Fields") diff --git a/tutorials/pde/2_advection_diffusion.py b/tutorials/pde/2_advection_diffusion.py index b71808f81..8783360db 100644 --- a/tutorials/pde/2_advection_diffusion.py +++ b/tutorials/pde/2_advection_diffusion.py @@ -204,14 +204,14 @@ # Define the matrix M Afc = mesh.dim * mesh.aveF2CC # modified averaging operator to sum dot product -Mf_inv = mesh.getFaceInnerProduct(invMat=True) -Mc = sdiag(mesh.vol) -Mc_inv = sdiag(1 / mesh.vol) -Mf_alpha_inv = mesh.getFaceInnerProduct(a, invProp=True, invMat=True) +Mf_inv = mesh.get_face_inner_product(invert_matrix=True) +Mc = sdiag(mesh.cell_volumes) +Mc_inv = sdiag(1 / mesh.cell_volumes) +Mf_alpha_inv = mesh.get_face_inner_product(a, invert_model=True, invert_matrix=True) -mesh.setCellGradBC(["neumann", "neumann"]) # Set Neumann BC -G = mesh.cellGrad -D = mesh.faceDiv +mesh.set_cell_gradient_BC(["neumann", "neumann"]) # Set Neumann BC +G = mesh.cell_gradient +D = mesh.face_divergence M = -D * Mf_alpha_inv * G * Mc + Afc * sdiag(u) * Mf_inv * G * Mc @@ -232,7 +232,7 @@ ax = 9 * [None] ax[0] = fig.add_subplot(332) -mesh.plotImage( +mesh.plot_image( u, ax=ax[0], v_type="F", @@ -256,7 +256,7 @@ if ii + 1 in (1, 25, 50, 100, 200, 300): ax[n] = fig.add_subplot(3, 3, n + 1) - mesh.plotImage(p, v_type="CC", ax=ax[n], pcolor_opts={"cmap": "gist_heat_r"}) + mesh.plot_image(p, v_type="CC", ax=ax[n], pcolor_opts={"cmap": "gist_heat_r"}) title_str = "p at t = " + str((ii + 1) * dt) + " s" ax[n].set_title(title_str) n = n + 1 From baebda8be3d155c57b9c196a6f1ea0bdf1783e5b Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Fri, 27 Jan 2023 16:31:03 -0800 Subject: [PATCH 09/16] Update deprecations for tests --- tests/base/test_basemesh.py | 57 +++--- tests/base/test_coordutils.py | 12 +- tests/base/test_curvilinear.py | 70 +++---- tests/base/test_curvilinear_vtk.py | 4 +- tests/base/test_interpolation.py | 40 ++-- tests/base/test_operators.py | 116 +++++------ tests/base/test_properties.py | 12 +- tests/base/test_tensor.py | 30 +-- tests/base/test_tensor_innerproduct.py | 150 +++++++------- tests/base/test_tensor_innerproduct_derivs.py | 44 ++-- tests/base/test_tensor_io.py | 28 +-- tests/base/test_tensor_omf.py | 14 +- tests/base/test_utils.py | 140 ++++++------- tests/base/test_view.py | 30 +-- tests/base/test_volume_avg.py | 46 ++--- tests/boundaries/test_tensor_boundary.py | 66 +++--- .../test_tensor_boundary_poisson.py | 96 ++++----- tests/cyl/test_cyl.py | 188 +++++++++--------- tests/cyl/test_cyl3D.py | 80 ++++---- tests/cyl/test_cylOperators.py | 42 ++-- tests/cyl/test_cyl_innerproducts.py | 124 ++++++------ tests/simplex/test_inner_products.py | 112 +++++------ tests/tree/test_tree.py | 84 ++++---- tests/tree/test_tree_innerproduct_derivs.py | 28 +-- tests/tree/test_tree_interpolation.py | 16 +- tests/tree/test_tree_io.py | 18 +- tests/tree/test_tree_operators.py | 178 ++++++++--------- 27 files changed, 913 insertions(+), 912 deletions(-) diff --git a/tests/base/test_basemesh.py b/tests/base/test_basemesh.py index 0faa35bea..2b40eeec1 100644 --- a/tests/base/test_basemesh.py +++ b/tests/base/test_basemesh.py @@ -97,9 +97,9 @@ def test_mesh_nc(self): self.assertEqual(self.mesh.vnC, (6, 2, 3)) def test_mesh_nc_xyz(self): - self.assertEqual(self.mesh.nCx, 6) - self.assertEqual(self.mesh.nCy, 2) - self.assertEqual(self.mesh.nCz, 3) + self.assertEqual(self.mesh.shape_cells[0], 6) + self.assertEqual(self.mesh.shape_cells[1], 2) + self.assertEqual(self.mesh.shape_cells[2], 3) def test_mesh_nf(self): self.assertEqual(self.mesh.vnFx, (7, 2, 3)) @@ -123,13 +123,13 @@ def test_mesh_r_E_V(self): ey = np.ones(self.mesh.nEy) * 2 ez = np.ones(self.mesh.nEz) * 3 e = np.r_[ex, ey, ez] - tex = self.mesh.r(e, "E", "Ex", "V") - tey = self.mesh.r(e, "E", "Ey", "V") - tez = self.mesh.r(e, "E", "Ez", "V") + tex = self.mesh.reshape(e, "E", "Ex", "V") + tey = self.mesh.reshape(e, "E", "Ey", "V") + tez = self.mesh.reshape(e, "E", "Ez", "V") self.assertTrue(np.all(tex == ex)) self.assertTrue(np.all(tey == ey)) self.assertTrue(np.all(tez == ez)) - tex, tey, tez = self.mesh.r(e, "E", "E", "V") + tex, tey, tez = self.mesh.reshape(e, "E", "E", "V") self.assertTrue(np.all(tex == ex)) self.assertTrue(np.all(tey == ey)) self.assertTrue(np.all(tez == ez)) @@ -139,13 +139,13 @@ def test_mesh_r_F_V(self): fy = np.ones(self.mesh.nFy) * 2 fz = np.ones(self.mesh.nFz) * 3 f = np.r_[fx, fy, fz] - tfx = self.mesh.r(f, "F", "Fx", "V") - tfy = self.mesh.r(f, "F", "Fy", "V") - tfz = self.mesh.r(f, "F", "Fz", "V") + tfx = self.mesh.reshape(f, "F", "Fx", "V") + tfy = self.mesh.reshape(f, "F", "Fy", "V") + tfz = self.mesh.reshape(f, "F", "Fz", "V") self.assertTrue(np.all(tfx == fx)) self.assertTrue(np.all(tfy == fy)) self.assertTrue(np.all(tfz == fz)) - tfx, tfy, tfz = self.mesh.r(f, "F", "F", "V") + tfx, tfy, tfz = self.mesh.reshape(f, "F", "F", "V") self.assertTrue(np.all(tfx == fx)) self.assertTrue(np.all(tfy == fy)) self.assertTrue(np.all(tfz == fz)) @@ -154,7 +154,7 @@ def test_mesh_r_E_M(self): g = np.ones((np.prod(self.mesh.vnEx), 3)) g[:, 1] = 2 g[:, 2] = 3 - Xex, Yex, Zex = self.mesh.r(g, "Ex", "Ex", "M") + Xex, Yex, Zex = self.mesh.reshape(g, "Ex", "Ex", "M") self.assertEqual(Xex.shape, self.mesh.vnEx) self.assertEqual(Yex.shape, self.mesh.vnEx) self.assertEqual(Zex.shape, self.mesh.vnEx) @@ -166,7 +166,7 @@ def test_mesh_r_F_M(self): g = np.ones((np.prod(self.mesh.vnFx), 3)) g[:, 1] = 2 g[:, 2] = 3 - Xfx, Yfx, Zfx = self.mesh.r(g, "Fx", "Fx", "M") + Xfx, Yfx, Zfx = self.mesh.reshape(g, "Fx", "Fx", "M") self.assertEqual(Xfx.shape, self.mesh.vnFx) self.assertEqual(Yfx.shape, self.mesh.vnFx) self.assertEqual(Zfx.shape, self.mesh.vnFx) @@ -178,7 +178,7 @@ def test_mesh_r_CC_M(self): g = np.ones((self.mesh.nC, 3)) g[:, 1] = 2 g[:, 2] = 3 - Xc, Yc, Zc = self.mesh.r(g, "CC", "CC", "M") + Xc, Yc, Zc = self.mesh.reshape(g, "CC", "CC", "M") self.assertEqual(Xc.shape, self.mesh.vnC) self.assertEqual(Yc.shape, self.mesh.vnC) self.assertEqual(Zc.shape, self.mesh.vnC) @@ -204,9 +204,8 @@ def test_mesh_nc(self): self.assertEqual(self.mesh.vnC, (6, 2)) def test_mesh_nc_xyz(self): - self.assertEqual(self.mesh.nCx, 6) - self.assertEqual(self.mesh.nCy, 2) - self.assertTrue(self.mesh.nCz is None) + self.assertEqual(self.mesh.shape_cells[0], 6) + self.assertEqual(self.mesh.shape_cells[1], 2) def test_mesh_nf(self): self.assertEqual(self.mesh.vnFx, (7, 2)) @@ -233,32 +232,34 @@ def test_mesh_r_E_V(self): ex = np.ones(self.mesh.nEx) ey = np.ones(self.mesh.nEy) * 2 e = np.r_[ex, ey] - tex = self.mesh.r(e, "E", "Ex", "V") - tey = self.mesh.r(e, "E", "Ey", "V") + tex = self.mesh.reshape(e, "E", "Ex", "V") + tey = self.mesh.reshape(e, "E", "Ey", "V") self.assertTrue(np.all(tex == ex)) self.assertTrue(np.all(tey == ey)) - tex, tey = self.mesh.r(e, "E", "E", "V") + tex, tey = self.mesh.reshape(e, "E", "E", "V") self.assertTrue(np.all(tex == ex)) self.assertTrue(np.all(tey == ey)) - self.assertRaises(Exception, self.mesh.r, e, "E", "Ez", "V") + with self.assertRaises(ValueError): + self.mesh.reshape(e, "E", "Ez", "V") def test_mesh_r_F_V(self): fx = np.ones(self.mesh.nFx) fy = np.ones(self.mesh.nFy) * 2 f = np.r_[fx, fy] - tfx = self.mesh.r(f, "F", "Fx", "V") - tfy = self.mesh.r(f, "F", "Fy", "V") + tfx = self.mesh.reshape(f, "F", "Fx", "V") + tfy = self.mesh.reshape(f, "F", "Fy", "V") self.assertTrue(np.all(tfx == fx)) self.assertTrue(np.all(tfy == fy)) - tfx, tfy = self.mesh.r(f, "F", "F", "V") + tfx, tfy = self.mesh.reshape(f, "F", "F", "V") self.assertTrue(np.all(tfx == fx)) self.assertTrue(np.all(tfy == fy)) - self.assertRaises(Exception, self.mesh.r, f, "F", "Fz", "V") + with self.assertRaises(ValueError): + self.mesh.reshape(f, "F", "Fz", "V") def test_mesh_r_E_M(self): g = np.ones((np.prod(self.mesh.vnEx), 2)) g[:, 1] = 2 - Xex, Yex = self.mesh.r(g, "Ex", "Ex", "M") + Xex, Yex = self.mesh.reshape(g, "Ex", "Ex", "M") self.assertEqual(Xex.shape, self.mesh.vnEx) self.assertEqual(Yex.shape, self.mesh.vnEx) self.assertTrue(np.all(Xex == 1)) @@ -267,7 +268,7 @@ def test_mesh_r_E_M(self): def test_mesh_r_F_M(self): g = np.ones((np.prod(self.mesh.vnFx), 2)) g[:, 1] = 2 - Xfx, Yfx = self.mesh.r(g, "Fx", "Fx", "M") + Xfx, Yfx = self.mesh.reshape(g, "Fx", "Fx", "M") self.assertEqual(Xfx.shape, self.mesh.vnFx) self.assertEqual(Yfx.shape, self.mesh.vnFx) self.assertTrue(np.all(Xfx == 1)) @@ -276,7 +277,7 @@ def test_mesh_r_F_M(self): def test_mesh_r_CC_M(self): g = np.ones((self.mesh.nC, 2)) g[:, 1] = 2 - Xc, Yc = self.mesh.r(g, "CC", "CC", "M") + Xc, Yc = self.mesh.reshape(g, "CC", "CC", "M") self.assertEqual(Xc.shape, self.mesh.vnC) self.assertEqual(Yc.shape, self.mesh.vnC) self.assertTrue(np.all(Xc == 1)) diff --git a/tests/base/test_coordutils.py b/tests/base/test_coordutils.py index d31f3d092..97d565df3 100644 --- a/tests/base/test_coordutils.py +++ b/tests/base/test_coordutils.py @@ -6,7 +6,7 @@ class coorutilsTest(unittest.TestCase): - def test_rotationMatrixFromNormals(self): + def test_rotation_matrix_from_normals(self): np.random.seed(0) v0 = np.random.rand(3) v0 *= 1.0 / np.linalg.norm(v0) @@ -15,13 +15,13 @@ def test_rotationMatrixFromNormals(self): v1 = np.random.rand(3) v1 *= 1.0 / np.linalg.norm(v1) - Rf = utils.rotationMatrixFromNormals(v0, v1) - Ri = utils.rotationMatrixFromNormals(v1, v0) + Rf = utils.rotation_matrix_from_normals(v0, v1) + Ri = utils.rotation_matrix_from_normals(v1, v0) self.assertTrue(np.linalg.norm(utils.mkvc(Rf.dot(v0) - v1)) < tol) self.assertTrue(np.linalg.norm(utils.mkvc(Ri.dot(v1) - v0)) < tol) - def test_rotatePointsFromNormals(self): + def test_rotate_points_from_normals(self): np.random.seed(10) v0 = np.random.rand(3) v0 *= 1.0 / np.linalg.norm(v0) @@ -30,7 +30,7 @@ def test_rotatePointsFromNormals(self): v1 = np.random.rand(3) v1 *= 1.0 / np.linalg.norm(v1) - v2 = utils.mkvc(utils.rotatePointsFromNormals(utils.mkvc(v0, 2).T, v0, v1)) + v2 = utils.mkvc(utils.rotate_points_from_normals(utils.mkvc(v0, 2).T, v0, v1)) self.assertTrue(np.linalg.norm(v2 - v1) < tol) @@ -48,7 +48,7 @@ def test_rotateMatrixFromNormals(self): XYZ0 = scale * n0 XYZ1 = scale * n1 - XYZ2 = utils.rotatePointsFromNormals(XYZ0, n0, n1) + XYZ2 = utils.rotate_points_from_normals(XYZ0, n0, n1) self.assertTrue( np.linalg.norm(utils.mkvc(XYZ1) - utils.mkvc(XYZ2)) / np.linalg.norm(utils.mkvc(XYZ1)) diff --git a/tests/base/test_curvilinear.py b/tests/base/test_curvilinear.py index c6fa0f58d..65cf5c9d2 100644 --- a/tests/base/test_curvilinear.py +++ b/tests/base/test_curvilinear.py @@ -77,16 +77,16 @@ def test_area_3D(self): 2, ] ) - self.assertTrue(np.all(self.Curv3.area == test_area)) + self.assertTrue(np.all(self.Curv3.face_areas == test_area)) def test_vol_3D(self): test_vol = np.array([1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8]) - np.testing.assert_almost_equal(self.Curv3.vol, test_vol) + np.testing.assert_almost_equal(self.Curv3.cell_volumes, test_vol) self.assertTrue(True) # Pass if you get past the assertion. def test_vol_2D(self): test_vol = np.array([1, 1, 1, 2, 2, 2]) - t1 = np.all(self.Curv2.vol == test_vol) + t1 = np.all(self.Curv2.cell_volumes == test_vol) self.assertTrue(t1) def test_edge_3D(self): @@ -169,104 +169,104 @@ def test_edge_3D(self): 4, ] ) - t1 = np.all(self.Curv3.edge == test_edge) + t1 = np.all(self.Curv3.edge_lengths == test_edge) self.assertTrue(t1) def test_edge_2D(self): test_edge = np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2]) - t1 = np.all(self.Curv2.edge == test_edge) + t1 = np.all(self.Curv2.edge_lengths == test_edge) self.assertTrue(t1) def test_tangents(self): - T = self.Curv2.tangents + T = self.Curv2.edge_tangents self.assertTrue( - np.all(self.Curv2.r(T, "E", "Ex", "V")[0] == np.ones(self.Curv2.nEx)) + np.all(self.Curv2.reshape(T, "E", "Ex", "V")[0] == np.ones(self.Curv2.nEx)) ) self.assertTrue( - np.all(self.Curv2.r(T, "E", "Ex", "V")[1] == np.zeros(self.Curv2.nEx)) + np.all(self.Curv2.reshape(T, "E", "Ex", "V")[1] == np.zeros(self.Curv2.nEx)) ) self.assertTrue( - np.all(self.Curv2.r(T, "E", "Ey", "V")[0] == np.zeros(self.Curv2.nEy)) + np.all(self.Curv2.reshape(T, "E", "Ey", "V")[0] == np.zeros(self.Curv2.nEy)) ) self.assertTrue( - np.all(self.Curv2.r(T, "E", "Ey", "V")[1] == np.ones(self.Curv2.nEy)) + np.all(self.Curv2.reshape(T, "E", "Ey", "V")[1] == np.ones(self.Curv2.nEy)) ) - T = self.Curv3.tangents + T = self.Curv3.edge_tangents self.assertTrue( - np.all(self.Curv3.r(T, "E", "Ex", "V")[0] == np.ones(self.Curv3.nEx)) + np.all(self.Curv3.reshape(T, "E", "Ex", "V")[0] == np.ones(self.Curv3.nEx)) ) self.assertTrue( - np.all(self.Curv3.r(T, "E", "Ex", "V")[1] == np.zeros(self.Curv3.nEx)) + np.all(self.Curv3.reshape(T, "E", "Ex", "V")[1] == np.zeros(self.Curv3.nEx)) ) self.assertTrue( - np.all(self.Curv3.r(T, "E", "Ex", "V")[2] == np.zeros(self.Curv3.nEx)) + np.all(self.Curv3.reshape(T, "E", "Ex", "V")[2] == np.zeros(self.Curv3.nEx)) ) self.assertTrue( - np.all(self.Curv3.r(T, "E", "Ey", "V")[0] == np.zeros(self.Curv3.nEy)) + np.all(self.Curv3.reshape(T, "E", "Ey", "V")[0] == np.zeros(self.Curv3.nEy)) ) self.assertTrue( - np.all(self.Curv3.r(T, "E", "Ey", "V")[1] == np.ones(self.Curv3.nEy)) + np.all(self.Curv3.reshape(T, "E", "Ey", "V")[1] == np.ones(self.Curv3.nEy)) ) self.assertTrue( - np.all(self.Curv3.r(T, "E", "Ey", "V")[2] == np.zeros(self.Curv3.nEy)) + np.all(self.Curv3.reshape(T, "E", "Ey", "V")[2] == np.zeros(self.Curv3.nEy)) ) self.assertTrue( - np.all(self.Curv3.r(T, "E", "Ez", "V")[0] == np.zeros(self.Curv3.nEz)) + np.all(self.Curv3.reshape(T, "E", "Ez", "V")[0] == np.zeros(self.Curv3.nEz)) ) self.assertTrue( - np.all(self.Curv3.r(T, "E", "Ez", "V")[1] == np.zeros(self.Curv3.nEz)) + np.all(self.Curv3.reshape(T, "E", "Ez", "V")[1] == np.zeros(self.Curv3.nEz)) ) self.assertTrue( - np.all(self.Curv3.r(T, "E", "Ez", "V")[2] == np.ones(self.Curv3.nEz)) + np.all(self.Curv3.reshape(T, "E", "Ez", "V")[2] == np.ones(self.Curv3.nEz)) ) def test_normals(self): - N = self.Curv2.normals + N = self.Curv2.face_normals self.assertTrue( - np.all(self.Curv2.r(N, "F", "Fx", "V")[0] == np.ones(self.Curv2.nFx)) + np.all(self.Curv2.reshape(N, "F", "Fx", "V")[0] == np.ones(self.Curv2.nFx)) ) self.assertTrue( - np.all(self.Curv2.r(N, "F", "Fx", "V")[1] == np.zeros(self.Curv2.nFx)) + np.all(self.Curv2.reshape(N, "F", "Fx", "V")[1] == np.zeros(self.Curv2.nFx)) ) self.assertTrue( - np.all(self.Curv2.r(N, "F", "Fy", "V")[0] == np.zeros(self.Curv2.nFy)) + np.all(self.Curv2.reshape(N, "F", "Fy", "V")[0] == np.zeros(self.Curv2.nFy)) ) self.assertTrue( - np.all(self.Curv2.r(N, "F", "Fy", "V")[1] == np.ones(self.Curv2.nFy)) + np.all(self.Curv2.reshape(N, "F", "Fy", "V")[1] == np.ones(self.Curv2.nFy)) ) - N = self.Curv3.normals + N = self.Curv3.face_normals self.assertTrue( - np.all(self.Curv3.r(N, "F", "Fx", "V")[0] == np.ones(self.Curv3.nFx)) + np.all(self.Curv3.reshape(N, "F", "Fx", "V")[0] == np.ones(self.Curv3.nFx)) ) self.assertTrue( - np.all(self.Curv3.r(N, "F", "Fx", "V")[1] == np.zeros(self.Curv3.nFx)) + np.all(self.Curv3.reshape(N, "F", "Fx", "V")[1] == np.zeros(self.Curv3.nFx)) ) self.assertTrue( - np.all(self.Curv3.r(N, "F", "Fx", "V")[2] == np.zeros(self.Curv3.nFx)) + np.all(self.Curv3.reshape(N, "F", "Fx", "V")[2] == np.zeros(self.Curv3.nFx)) ) self.assertTrue( - np.all(self.Curv3.r(N, "F", "Fy", "V")[0] == np.zeros(self.Curv3.nFy)) + np.all(self.Curv3.reshape(N, "F", "Fy", "V")[0] == np.zeros(self.Curv3.nFy)) ) self.assertTrue( - np.all(self.Curv3.r(N, "F", "Fy", "V")[1] == np.ones(self.Curv3.nFy)) + np.all(self.Curv3.reshape(N, "F", "Fy", "V")[1] == np.ones(self.Curv3.nFy)) ) self.assertTrue( - np.all(self.Curv3.r(N, "F", "Fy", "V")[2] == np.zeros(self.Curv3.nFy)) + np.all(self.Curv3.reshape(N, "F", "Fy", "V")[2] == np.zeros(self.Curv3.nFy)) ) self.assertTrue( - np.all(self.Curv3.r(N, "F", "Fz", "V")[0] == np.zeros(self.Curv3.nFz)) + np.all(self.Curv3.reshape(N, "F", "Fz", "V")[0] == np.zeros(self.Curv3.nFz)) ) self.assertTrue( - np.all(self.Curv3.r(N, "F", "Fz", "V")[1] == np.zeros(self.Curv3.nFz)) + np.all(self.Curv3.reshape(N, "F", "Fz", "V")[1] == np.zeros(self.Curv3.nFz)) ) self.assertTrue( - np.all(self.Curv3.r(N, "F", "Fz", "V")[2] == np.ones(self.Curv3.nFz)) + np.all(self.Curv3.reshape(N, "F", "Fz", "V")[2] == np.ones(self.Curv3.nFz)) ) def test_grid(self): diff --git a/tests/base/test_curvilinear_vtk.py b/tests/base/test_curvilinear_vtk.py index 7a8a02304..b48e042aa 100644 --- a/tests/base/test_curvilinear_vtk.py +++ b/tests/base/test_curvilinear_vtk.py @@ -17,7 +17,7 @@ class TestCurvilinearMeshVTK(unittest.TestCase): def setUp(self): sz = [16, 16, 16] mesh = discretize.CurvilinearMesh( - discretize.utils.exampleLrmGrid(sz, "rotate") + discretize.utils.example_curvilinear_grid(sz, "rotate") ) self.mesh = mesh @@ -50,7 +50,7 @@ def test_VTK_file_IO(self): mesh = self.mesh vec = np.arange(mesh.nC) models = {"arange.txt": vec} - mesh.writeVTK("temp.vts", models) + mesh.write_vtk("temp.vts", models) print("Writing of VTK files is working") os.remove("temp.vts") diff --git a/tests/base/test_interpolation.py b/tests/base/test_interpolation.py index 001731394..c9826128a 100644 --- a/tests/base/test_interpolation.py +++ b/tests/base/test_interpolation.py @@ -60,7 +60,7 @@ def getError(self): elif "N" == self.type: grid = call1(funX, self.M.gridN) - comp = self.M.getInterpolationMat(self.LOCS, self.type) * grid + comp = self.M.get_interpolation_matrix(self.LOCS, self.type) * grid err = np.linalg.norm((comp - ana), 2) return err @@ -82,12 +82,12 @@ def setUp(self): def test_outliers(self): M = discretize.TensorMesh([4]) - Q = M.getInterpolationMat( + Q = M.get_interpolation_matrix( np.array([[0], [0.126], [0.127]]), "CC", zeros_outside=True ) x = np.arange(4) + 1 self.assertTrue(np.linalg.norm(Q * x - np.r_[1, 1.004, 1.008]) < TOL) - Q = M.getInterpolationMat( + Q = M.get_interpolation_matrix( np.array([[-1], [0.126], [0.127]]), "CC", zeros_outside=True ) self.assertTrue(np.linalg.norm(Q * x - np.r_[0, 1.004, 1.008]) < TOL) @@ -114,16 +114,16 @@ def getError(self): if "F" in self.type: Fc = cartF2(self.M, funX, funY) - grid = self.M.projectFaceVector(Fc) + grid = self.M.project_face_vector(Fc) elif "E" in self.type: Ec = cartE2(self.M, funX, funY) - grid = self.M.projectEdgeVector(Ec) + grid = self.M.project_edge_vector(Ec) elif "CC" == self.type: grid = call2(funX, self.M.gridCC) elif "N" == self.type: grid = call2(funX, self.M.gridN) - comp = self.M.getInterpolationMat(self.LOCS, self.type) * grid + comp = self.M.get_interpolation_matrix(self.LOCS, self.type) * grid err = np.linalg.norm((comp - ana), np.inf) return err @@ -161,19 +161,19 @@ def test_orderEy(self): class TestInterpolationSymmetricCyl_Simple(unittest.TestCase): def test_simpleInter(self): - M = discretize.CylMesh([4, 1, 1]) + M = discretize.CylindricalMesh([4, 1, 1]) locs = np.r_[0, 0, 0.5] fx = np.array([[1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]) - self.assertTrue(np.all(fx == M.getInterpolationMat(locs, "Fx").todense())) + self.assertTrue(np.all(fx == M.get_interpolation_matrix(locs, "Fx").todense())) fz = np.array([[0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0]]) - self.assertTrue(np.all(fz == M.getInterpolationMat(locs, "Fz").todense())) + self.assertTrue(np.all(fz == M.get_interpolation_matrix(locs, "Fz").todense())) def test_exceptions(self): - M = discretize.CylMesh([4, 1, 1]) + M = discretize.CylindricalMesh([4, 1, 1]) locs = np.r_[0, 0, 0.5] - self.assertRaises(Exception, lambda: M.getInterpolationMat(locs, "Fy")) - self.assertRaises(Exception, lambda: M.getInterpolationMat(locs, "Ex")) - self.assertRaises(Exception, lambda: M.getInterpolationMat(locs, "Ez")) + self.assertRaises(Exception, lambda: M.get_interpolation_matrix(locs, "Fy")) + self.assertRaises(Exception, lambda: M.get_interpolation_matrix(locs, "Ex")) + self.assertRaises(Exception, lambda: M.get_interpolation_matrix(locs, "Ez")) class TestInterpolationSymCyl(discretize.tests.OrderTest): @@ -202,12 +202,12 @@ def getError(self): if "Fx" == self.type: Fc = cartF2Cyl(self.M, funX, funY) Fc = np.c_[Fc[:, 0], np.zeros(self.M.nF), Fc[:, 1]] - grid = self.M.projectFaceVector(Fc) + grid = self.M.project_face_vector(Fc) elif "Fz" == self.type: Fc = cartF2Cyl(self.M, funX, funY) Fc = np.c_[Fc[:, 0], np.zeros(self.M.nF), Fc[:, 1]] - grid = self.M.projectFaceVector(Fc) + grid = self.M.project_face_vector(Fc) elif "E" in self.type: Ec = cartE2Cyl(self.M, funX, funY) grid = Ec[:, 1] @@ -216,7 +216,7 @@ def getError(self): elif "N" == self.type: grid = call2(funX, self.M.gridN) - comp = self.M.getInterpolationMat(self.LOCS, self.type) * grid + comp = self.M.get_interpolation_matrix(self.LOCS, self.type) * grid err = np.linalg.norm((comp - ana), np.inf) return err @@ -267,7 +267,7 @@ def getError(self): elif "N" == self.type: v = func(*mesh.nodes.T) - comp = mesh.getInterpolationMat(self.LOCS, self.type) * v + comp = mesh.get_interpolation_matrix(self.LOCS, self.type) * v err = np.linalg.norm((comp - ana), np.inf) return err @@ -337,16 +337,16 @@ def getError(self): if "F" in self.type: Fc = cartF3(self.M, funX, funY, funZ) - grid = self.M.projectFaceVector(Fc) + grid = self.M.project_face_vector(Fc) elif "E" in self.type: Ec = cartE3(self.M, funX, funY, funZ) - grid = self.M.projectEdgeVector(Ec) + grid = self.M.project_edge_vector(Ec) elif "CC" == self.type: grid = call3(funX, self.M.gridCC) elif "N" == self.type: grid = call3(funX, self.M.gridN) - comp = self.M.getInterpolationMat(self.LOCS, self.type) * grid + comp = self.M.get_interpolation_matrix(self.LOCS, self.type) * grid err = np.linalg.norm((comp - ana), np.inf) return err diff --git a/tests/base/test_operators.py b/tests/base/test_operators.py index 250cbd0a0..4f0b0d72f 100644 --- a/tests/base/test_operators.py +++ b/tests/base/test_operators.py @@ -59,16 +59,16 @@ def getError(self): solZ = lambda x, y, z: 2 * np.pi * np.sin(2 * np.pi * y) Ec = cartE3(self.M, funX, funY, funZ) - E = self.M.projectEdgeVector(Ec) + E = self.M.project_edge_vector(Ec) Fc = cartF3(self.M, solX, solY, solZ) - curlE_ana = self.M.projectFaceVector(Fc) + curlE_ana = self.M.project_face_vector(Fc) - curlE = self.M.edgeCurl.dot(E) + curlE = self.M.edge_curl.dot(E) if self._meshType == "rotateCurv": # Really it is the integration we should be caring about: # So, let us look at the l2 norm. - err = np.linalg.norm(self.M.area * (curlE - curlE_ana), 2) + err = np.linalg.norm(self.M.face_areas * (curlE - curlE_ana), 2) else: err = np.linalg.norm((curlE - curlE_ana), np.inf) return err @@ -91,7 +91,7 @@ def getError(self): sol_curl2d = call2(sol, self.M.gridCC) Ec = cartE2(self.M, ex, ey) - sol_ana = self.M.edgeCurl * self.M.projectFaceVector(Ec) + sol_ana = self.M.edge_curl * self.M.project_face_vector(Ec) err = np.linalg.norm((sol_curl2d - sol_ana), np.inf) return err @@ -100,34 +100,34 @@ def test_order(self): self.orderTest() -class TestCellGrad1D_InhomogeneousDirichlet(discretize.tests.OrderTest): - name = "Cell Grad 1D - Dirichlet" - meshTypes = ["uniformTensorMesh"] - meshDimension = 1 - expectedOrders = ( - 1 # because of the averaging involved in the ghost point. u_b = (u_n + u_g)/2 - ) - meshSizes = [8, 16, 32, 64] - - def getError(self): - # Test function - fx = lambda x: -2 * np.pi * np.sin(2 * np.pi * x) - sol = lambda x: np.cos(2 * np.pi * x) - - xc = sol(self.M.gridCC) - - gradX_ana = fx(self.M.gridFx) - - bc = np.array([1, 1]) - self.M.setCellGradBC("dirichlet") - gradX = self.M.cellGrad.dot(xc) + self.M.cellGradBC * bc - - err = np.linalg.norm((gradX - gradX_ana), np.inf) - - return err - - def test_order(self): - self.orderTest() +# class TestCellGrad1D_InhomogeneousDirichlet(discretize.tests.OrderTest): +# name = "Cell Grad 1D - Dirichlet" +# meshTypes = ["uniformTensorMesh"] +# meshDimension = 1 +# expectedOrders = ( +# 1 # because of the averaging involved in the ghost point. u_b = (u_n + u_g)/2 +# ) +# meshSizes = [8, 16, 32, 64] +# +# def getError(self): +# # Test function +# fx = lambda x: -2 * np.pi * np.sin(2 * np.pi * x) +# sol = lambda x: np.cos(2 * np.pi * x) +# +# xc = sol(self.M.gridCC) +# +# gradX_ana = fx(self.M.gridFx) +# +# bc = np.array([1, 1]) +# self.M.set_cell_gradient_BC("dirichlet") +# gradX = self.M.cell_gradient.dot(xc) + self.M.cellGradBC * bc +# +# err = np.linalg.norm((gradX - gradX_ana), np.inf) +# +# return err +# +# def test_order(self): +# self.orderTest() class TestCellGrad2D_Dirichlet(discretize.tests.OrderTest): @@ -145,10 +145,10 @@ def getError(self): xc = call2(sol, self.M.gridCC) Fc = cartF2(self.M, fx, fy) - gradX_ana = self.M.projectFaceVector(Fc) + gradX_ana = self.M.project_face_vector(Fc) - self.M.setCellGradBC("dirichlet") - gradX = self.M.cellGrad.dot(xc) + self.M.set_cell_gradient_BC("dirichlet") + gradX = self.M.cell_gradient.dot(xc) err = np.linalg.norm((gradX - gradX_ana), np.inf) @@ -196,10 +196,10 @@ def getError(self): xc = call3(sol, self.M.gridCC) Fc = cartF3(self.M, fx, fy, fz) - gradX_ana = self.M.projectFaceVector(Fc) + gradX_ana = self.M.project_face_vector(Fc) - self.M.setCellGradBC("dirichlet") - gradX = self.M.cellGrad.dot(xc) + self.M.set_cell_gradient_BC("dirichlet") + gradX = self.M.cell_gradient.dot(xc) err = np.linalg.norm((gradX - gradX_ana), np.inf) @@ -224,10 +224,10 @@ def getError(self): xc = call2(sol, self.M.gridCC) Fc = cartF2(self.M, fx, fy) - gradX_ana = self.M.projectFaceVector(Fc) + gradX_ana = self.M.project_face_vector(Fc) - self.M.setCellGradBC("neumann") - gradX = self.M.cellGrad.dot(xc) + self.M.set_cell_gradient_BC("neumann") + gradX = self.M.cell_gradient.dot(xc) err = np.linalg.norm((gradX - gradX_ana), np.inf) @@ -275,10 +275,10 @@ def getError(self): xc = call3(sol, self.M.gridCC) Fc = cartF3(self.M, fx, fy, fz) - gradX_ana = self.M.projectFaceVector(Fc) + gradX_ana = self.M.project_face_vector(Fc) - self.M.setCellGradBC("neumann") - gradX = self.M.cellGrad.dot(xc) + self.M.set_cell_gradient_BC("neumann") + gradX = self.M.cell_gradient.dot(xc) err = np.linalg.norm((gradX - gradX_ana), np.inf) @@ -305,15 +305,15 @@ def getError(self): ) Fc = cartF3(self.M, fx, fy, fz) - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) - divF = self.M.faceDiv.dot(F) + divF = self.M.face_divergence.dot(F) divF_ana = call3(sol, self.M.gridCC) if self._meshType == "rotateCurv": # Really it is the integration we should be caring about: # So, let us look at the l2 norm. - err = np.linalg.norm(self.M.vol * (divF - divF_ana), 2) + err = np.linalg.norm(self.M.cell_volumes * (divF - divF_ana), 2) else: err = np.linalg.norm((divF - divF_ana), np.inf) return err @@ -335,9 +335,9 @@ def getError(self): sol = lambda x, y: 2 * np.pi * (np.cos(2 * np.pi * x) + np.cos(2 * np.pi * y)) Fc = cartF2(self.M, fx, fy) - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) - divF = self.M.faceDiv.dot(F) + divF = self.M.face_divergence.dot(F) divF_ana = call2(sol, self.M.gridCC) err = np.linalg.norm((divF - divF_ana), np.inf) @@ -361,10 +361,10 @@ def getError(self): solZ = lambda x, y, z: -np.sin(z) phi = call3(fun, self.M.gridN) - gradE = self.M.nodalGrad.dot(phi) + gradE = self.M.nodal_gradient.dot(phi) Ec = cartE3(self.M, solX, solY, solZ) - gradE_ana = self.M.projectEdgeVector(Ec) + gradE_ana = self.M.project_edge_vector(Ec) err = np.linalg.norm((gradE - gradE_ana), np.inf) @@ -387,10 +387,10 @@ def getError(self): solY = lambda x, y: -np.sin(y) phi = call2(fun, self.M.gridN) - gradE = self.M.nodalGrad.dot(phi) + gradE = self.M.nodal_gradient.dot(phi) Ec = cartE2(self.M, solX, solY) - gradE_ana = self.M.projectEdgeVector(Ec) + gradE_ana = self.M.project_edge_vector(Ec) err = np.linalg.norm((gradE - gradE_ana), np.inf) @@ -777,11 +777,11 @@ class MimeticProperties(unittest.TestCase): def test_DivCurl(self): for meshType in self.meshTypes: - mesh, _ = discretize.tests.setupMesh( + mesh, _ = discretize.tests.setup_mesh( meshType, self.meshSize, self.meshDimension ) v = np.random.rand(mesh.nE) - divcurlv = mesh.faceDiv * (mesh.edgeCurl * v) + divcurlv = mesh.face_divergence * (mesh.edge_curl * v) rel_err = np.linalg.norm(divcurlv) / np.linalg.norm(v) passed = rel_err < self.tol print( @@ -791,11 +791,11 @@ def test_DivCurl(self): def test_CurlGrad(self): for meshType in self.meshTypes: - mesh, _ = discretize.tests.setupMesh( + mesh, _ = discretize.tests.setup_mesh( meshType, self.meshSize, self.meshDimension ) v = np.random.rand(mesh.nN) - curlgradv = mesh.edgeCurl * (mesh.nodalGrad * v) + curlgradv = mesh.edge_curl * (mesh.nodal_gradient * v) rel_err = np.linalg.norm(curlgradv) / np.linalg.norm(v) passed = rel_err < self.tol print( diff --git a/tests/base/test_properties.py b/tests/base/test_properties.py index 3d71e2382..d294dcd75 100644 --- a/tests/base/test_properties.py +++ b/tests/base/test_properties.py @@ -27,8 +27,8 @@ def compare_meshes(test, mesh0, mesh1): test.assertEqual(mesh0.vnF, mesh1.vnF) test.assertEqual(mesh0.vnN, mesh1.vnN) - test.assertTrue((mesh0.normals == mesh1.normals).all()) - test.assertTrue((mesh0.tangents == mesh1.tangents).all()) + test.assertTrue((mesh0.face_normals == mesh1.face_normals).all()) + test.assertTrue((mesh0.edge_tangents == mesh1.edge_tangents).all()) if hasattr(mesh0, "h"): for i in range(len(mesh0.h)): @@ -37,9 +37,9 @@ def compare_meshes(test, mesh0, mesh1): ) # check edges, faces, volumes - test.assertTrue((mesh0.edge == mesh1.edge).all()) - test.assertTrue((mesh0.area == mesh1.area).all()) - test.assertTrue((mesh0.vol == mesh1.vol).all()) + test.assertTrue((mesh0.edge_lengths == mesh1.edge_lengths).all()) + test.assertTrue((mesh0.face_areas == mesh1.face_areas).all()) + test.assertTrue((mesh0.cell_volumes == mesh1.cell_volumes).all()) # Tree mesh specific # if hasattr(mesh0, '_cells'): @@ -89,7 +89,7 @@ class CylTest(unittest.TestCase): n = [4, 1, 9] def setUp(self): - self.mesh = discretize.CylMesh(self.n, x0="00C") + self.mesh = discretize.CylindricalMesh(self.n, x0="00C") def test_save_load(self): print("\nTesting save / load of Cyl Mesh ...") diff --git a/tests/base/test_tensor.py b/tests/base/test_tensor.py index 4976bad1a..21f605fd2 100644 --- a/tests/base/test_tensor.py +++ b/tests/base/test_tensor.py @@ -36,16 +36,16 @@ def test_gridded_3D(self): def test_vectorN_2D(self): testNx = np.array([3, 4, 5, 6]) testNy = np.array([5, 6, 8]) - xtest = np.all(self.mesh2.vectorNx == testNx) - ytest = np.all(self.mesh2.vectorNy == testNy) + xtest = np.all(self.mesh2.nodes_x == testNx) + ytest = np.all(self.mesh2.nodes_y == testNy) self.assertTrue(xtest and ytest) def test_vectorCC_2D(self): testNx = np.array([3.5, 4.5, 5.5]) testNy = np.array([5.5, 7]) - xtest = np.all(self.mesh2.vectorCCx == testNx) - ytest = np.all(self.mesh2.vectorCCy == testNy) + xtest = np.all(self.mesh2.cell_centers_x == testNx) + ytest = np.all(self.mesh2.cell_centers_y == testNy) self.assertTrue(xtest and ytest) def test_area_3D(self): @@ -105,17 +105,17 @@ def test_area_3D(self): 2, ] ) - t1 = np.all(self.mesh3.area == test_area) + t1 = np.all(self.mesh3.face_areas == test_area) self.assertTrue(t1) def test_vol_3D(self): test_vol = np.array([1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8]) - t1 = np.all(self.mesh3.vol == test_vol) + t1 = np.all(self.mesh3.cell_volumes == test_vol) self.assertTrue(t1) def test_vol_2D(self): test_vol = np.array([1, 1, 1, 2, 2, 2]) - t1 = np.all(self.mesh2.vol == test_vol) + t1 = np.all(self.mesh2.cell_volumes == test_vol) self.assertTrue(t1) def test_edge_3D(self): @@ -198,12 +198,12 @@ def test_edge_3D(self): 4, ] ) - t1 = np.all(self.mesh3.edge == test_edge) + t1 = np.all(self.mesh3.edge_lengths == test_edge) self.assertTrue(t1) def test_edge_2D(self): test_edge = np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2]) - t1 = np.all(self.mesh2.edge == test_edge) + t1 = np.all(self.mesh2.edge_lengths == test_edge) self.assertTrue(t1) def test_oneCell(self): @@ -239,14 +239,14 @@ def test_cent_neg(self): def test_tensor(self): M = discretize.TensorMesh([[(10.0, 2)]]) - self.assertLess(np.abs(M.hx - np.r_[10.0, 10.0]).sum(), TOL) + self.assertLess(np.abs(M.h[0] - np.r_[10.0, 10.0]).sum(), TOL) def test_serialization(self): mesh = discretize.TensorMesh.deserialize(self.mesh2.serialize()) self.assertTrue(np.all(self.mesh2.x0 == mesh.x0)) self.assertTrue(np.all(self.mesh2.shape_cells == mesh.shape_cells)) - self.assertTrue(np.all(self.mesh2.hx == mesh.hx)) - self.assertTrue(np.all(self.mesh2.hy == mesh.hy)) + self.assertTrue(np.all(self.mesh2.h[0] == mesh.h[0])) + self.assertTrue(np.all(self.mesh2.h[1] == mesh.h[1])) self.assertTrue(np.all(self.mesh2.gridCC == mesh.gridCC)) @@ -263,10 +263,10 @@ def getError(self): ) sol = lambda x: -3.0 * ((2 * np.pi) ** 2) * fun(x) - self.M.setCellGradBC("dirichlet") + self.M.set_cell_gradient_BC("dirichlet") - D = self.M.faceDiv - G = self.M.cellGrad + D = self.M.face_divergence + G = self.M.cell_gradient if self.forward: sA = sol(self.M.gridCC) sN = D * G * fun(self.M.gridCC) diff --git a/tests/base/test_tensor_innerproduct.py b/tests/base/test_tensor_innerproduct.py index 884b2d70e..bee36cca5 100644 --- a/tests/base/test_tensor_innerproduct.py +++ b/tests/base/test_tensor_innerproduct.py @@ -48,28 +48,28 @@ def getError(self): Ec = np.vstack( (cart(self.M.gridEx), cart(self.M.gridEy), cart(self.M.gridEz)) ) - E = self.M.projectEdgeVector(Ec) + E = self.M.project_edge_vector(Ec) - if self.invProp: - A = self.M.getEdgeInnerProduct( - discretize.utils.invPropertyTensor(self.M, sigma), invProp=True + if self.invert_model: + A = self.M.get_edge_inner_product( + discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True ) else: - A = self.M.getEdgeInnerProduct(sigma) + A = self.M.get_edge_inner_product(sigma) numeric = E.T.dot(A.dot(E)) elif self.location == "faces": cart = lambda g: np.c_[call(ex, g), call(ey, g), call(ez, g)] Fc = np.vstack( (cart(self.M.gridFx), cart(self.M.gridFy), cart(self.M.gridFz)) ) - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) - if self.invProp: - A = self.M.getFaceInnerProduct( - discretize.utils.invPropertyTensor(self.M, sigma), invProp=True + if self.invert_model: + A = self.M.get_face_inner_product( + discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True ) else: - A = self.M.getFaceInnerProduct(sigma) + A = self.M.get_face_inner_product(sigma) numeric = F.T.dot(A.dot(F)) err = np.abs(numeric - analytic) @@ -79,84 +79,84 @@ def test_order1_edges(self): self.name = "Edge Inner Product - Isotropic" self.location = "edges" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_edges_invProp(self): - self.name = "Edge Inner Product - Isotropic - invProp" + def test_order1_edges_invert_model(self): + self.name = "Edge Inner Product - Isotropic - invert_model" self.location = "edges" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() def test_order3_edges(self): self.name = "Edge Inner Product - Anisotropic" self.location = "edges" self.sigmaTest = 3 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order3_edges_invProp(self): - self.name = "Edge Inner Product - Anisotropic - invProp" + def test_order3_edges_invert_model(self): + self.name = "Edge Inner Product - Anisotropic - invert_model" self.location = "edges" self.sigmaTest = 3 - self.invProp = True + self.invert_model = True self.orderTest() def test_order6_edges(self): self.name = "Edge Inner Product - Full Tensor" self.location = "edges" self.sigmaTest = 6 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order6_edges_invProp(self): - self.name = "Edge Inner Product - Full Tensor - invProp" + def test_order6_edges_invert_model(self): + self.name = "Edge Inner Product - Full Tensor - invert_model" self.location = "edges" self.sigmaTest = 6 - self.invProp = True + self.invert_model = True self.orderTest() def test_order1_faces(self): self.name = "Face Inner Product - Isotropic" self.location = "faces" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_faces_invProp(self): - self.name = "Face Inner Product - Isotropic - invProp" + def test_order1_faces_invert_model(self): + self.name = "Face Inner Product - Isotropic - invert_model" self.location = "faces" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() def test_order3_faces(self): self.name = "Face Inner Product - Anisotropic" self.location = "faces" self.sigmaTest = 3 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order3_faces_invProp(self): - self.name = "Face Inner Product - Anisotropic - invProp" + def test_order3_faces_invert_model(self): + self.name = "Face Inner Product - Anisotropic - invert_model" self.location = "faces" self.sigmaTest = 3 - self.invProp = True + self.invert_model = True self.orderTest() def test_order6_faces(self): self.name = "Face Inner Product - Full Tensor" self.location = "faces" self.sigmaTest = 6 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order6_faces_invProp(self): - self.name = "Face Inner Product - Full Tensor - invProp" + def test_order6_faces_invert_model(self): + self.name = "Face Inner Product - Full Tensor - invert_model" self.location = "faces" self.sigmaTest = 6 - self.invProp = True + self.invert_model = True self.orderTest() @@ -194,25 +194,25 @@ def getError(self): if self.location == "edges": cart = lambda g: np.c_[call(ex, g), call(ey, g)] Ec = np.vstack((cart(self.M.gridEx), cart(self.M.gridEy))) - E = self.M.projectEdgeVector(Ec) - if self.invProp: - A = self.M.getEdgeInnerProduct( - discretize.utils.invPropertyTensor(self.M, sigma), invProp=True + E = self.M.project_edge_vector(Ec) + if self.invert_model: + A = self.M.get_edge_inner_product( + discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True ) else: - A = self.M.getEdgeInnerProduct(sigma) + A = self.M.get_edge_inner_product(sigma) numeric = E.T.dot(A.dot(E)) elif self.location == "faces": cart = lambda g: np.c_[call(ex, g), call(ey, g)] Fc = np.vstack((cart(self.M.gridFx), cart(self.M.gridFy))) - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) - if self.invProp: - A = self.M.getFaceInnerProduct( - discretize.utils.invPropertyTensor(self.M, sigma), invProp=True + if self.invert_model: + A = self.M.get_face_inner_product( + discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True ) else: - A = self.M.getFaceInnerProduct(sigma) + A = self.M.get_face_inner_product(sigma) numeric = F.T.dot(A.dot(F)) err = np.abs(numeric - analytic) @@ -222,84 +222,84 @@ def test_order1_edges(self): self.name = "2D Edge Inner Product - Isotropic" self.location = "edges" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_edges_invProp(self): - self.name = "2D Edge Inner Product - Isotropic - invProp" + def test_order1_edges_invert_model(self): + self.name = "2D Edge Inner Product - Isotropic - invert_model" self.location = "edges" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() def test_order3_edges(self): self.name = "2D Edge Inner Product - Anisotropic" self.location = "edges" self.sigmaTest = 2 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order3_edges_invProp(self): - self.name = "2D Edge Inner Product - Anisotropic - invProp" + def test_order3_edges_invert_model(self): + self.name = "2D Edge Inner Product - Anisotropic - invert_model" self.location = "edges" self.sigmaTest = 2 - self.invProp = True + self.invert_model = True self.orderTest() def test_order6_edges(self): self.name = "2D Edge Inner Product - Full Tensor" self.location = "edges" self.sigmaTest = 3 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order6_edges_invProp(self): - self.name = "2D Edge Inner Product - Full Tensor - invProp" + def test_order6_edges_invert_model(self): + self.name = "2D Edge Inner Product - Full Tensor - invert_model" self.location = "edges" self.sigmaTest = 3 - self.invProp = True + self.invert_model = True self.orderTest() def test_order1_faces(self): self.name = "2D Face Inner Product - Isotropic" self.location = "faces" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_faces_invProp(self): - self.name = "2D Face Inner Product - Isotropic - invProp" + def test_order1_faces_invert_model(self): + self.name = "2D Face Inner Product - Isotropic - invert_model" self.location = "faces" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() def test_order2_faces(self): self.name = "2D Face Inner Product - Anisotropic" self.location = "faces" self.sigmaTest = 2 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order2_faces_invProp(self): - self.name = "2D Face Inner Product - Anisotropic - invProp" + def test_order2_faces_invert_model(self): + self.name = "2D Face Inner Product - Anisotropic - invert_model" self.location = "faces" self.sigmaTest = 2 - self.invProp = True + self.invert_model = True self.orderTest() def test_order3_faces(self): self.name = "2D Face Inner Product - Full Tensor" self.location = "faces" self.sigmaTest = 3 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order3_faces_invProp(self): - self.name = "2D Face Inner Product - Full Tensor - invProp" + def test_order3_faces_invert_model(self): + self.name = "2D Face Inner Product - Full Tensor - invert_model" self.location = "faces" self.sigmaTest = 3 - self.invProp = True + self.invert_model = True self.orderTest() @@ -327,10 +327,10 @@ def getError(self): if self.location == "faces": F = call(ex, self.M.gridFx) - if self.invProp: - A = self.M.getFaceInnerProduct(1 / sigma, invProp=True) + if self.invert_model: + A = self.M.get_face_inner_product(1 / sigma, invert_model=True) else: - A = self.M.getFaceInnerProduct(sigma) + A = self.M.get_face_inner_product(sigma) numeric = F.T.dot(A.dot(F)) err = np.abs(numeric - analytic) @@ -340,14 +340,14 @@ def test_order1_faces(self): self.name = "1D Face Inner Product" self.location = "faces" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_faces_invProp(self): - self.name = "1D Face Inner Product - invProp" + def test_order1_faces_invert_model(self): + self.name = "1D Face Inner Product - invert_model" self.location = "faces" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() diff --git a/tests/base/test_tensor_innerproduct_derivs.py b/tests/base/test_tensor_innerproduct_derivs.py index dd60294c3..1b7eb9c9c 100644 --- a/tests/base/test_tensor_innerproduct_derivs.py +++ b/tests/base/test_tensor_innerproduct_derivs.py @@ -6,9 +6,9 @@ class TestInnerProductsDerivsTensor(unittest.TestCase): - def doTestFace(self, h, rep, fast, meshType, invProp=False, invMat=False): + def doTestFace(self, h, rep, fast, meshType, invert_model=False, invert_matrix=False): if meshType == "Curv": - hRect = discretize.utils.exampleLrmGrid(h, "rotate") + hRect = discretize.utils.example_curvilinear_grid(h, "rotate") mesh = discretize.CurvilinearMesh(hRect) elif meshType == "Tree": mesh = discretize.TreeMesh(h, levels=3) @@ -20,9 +20,9 @@ def doTestFace(self, h, rep, fast, meshType, invProp=False, invMat=False): sig = np.random.rand(1) if rep == 0 else np.random.rand(mesh.nC * rep) def fun(sig): - M = mesh.getFaceInnerProduct(sig, invProp=invProp, invMat=invMat) - Md = mesh.getFaceInnerProductDeriv( - sig, invProp=invProp, invMat=invMat, doFast=fast + M = mesh.get_face_inner_product(sig, invert_model=invert_model, invert_matrix=invert_matrix) + Md = mesh.get_face_inner_product_deriv( + sig, invert_model=invert_model, invert_matrix=invert_matrix, do_fast=fast ) return M * v, Md(v) @@ -32,13 +32,13 @@ def fun(sig): h, rep, fast, - ("harmonic" if invProp and invMat else "standard"), + ("harmonic" if invert_model and invert_matrix else "standard"), ) - return discretize.tests.checkDerivative(fun, sig, num=5, plotIt=False) + return discretize.tests.check_derivative(fun, sig, num=5, plotIt=False) - def doTestEdge(self, h, rep, fast, meshType, invProp=False, invMat=False): + def doTestEdge(self, h, rep, fast, meshType, invert_model=False, invert_matrix=False): if meshType == "Curv": - hRect = discretize.utils.exampleLrmGrid(h, "rotate") + hRect = discretize.utils.example_curvilinear_grid(h, "rotate") mesh = discretize.CurvilinearMesh(hRect) elif meshType == "Tree": mesh = discretize.TreeMesh(h, levels=3) @@ -50,9 +50,9 @@ def doTestEdge(self, h, rep, fast, meshType, invProp=False, invMat=False): sig = np.random.rand(1) if rep == 0 else np.random.rand(mesh.nC * rep) def fun(sig): - M = mesh.getEdgeInnerProduct(sig, invProp=invProp, invMat=invMat) - Md = mesh.getEdgeInnerProductDeriv( - sig, invProp=invProp, invMat=invMat, doFast=fast + M = mesh.get_edge_inner_product(sig, invert_model=invert_model, invert_matrix=invert_matrix) + Md = mesh.get_edge_inner_product_deriv( + sig, invert_model=invert_model, invert_matrix=invert_matrix, do_fast=fast ) return M * v, Md(v) @@ -62,9 +62,9 @@ def fun(sig): h, rep, fast, - ("harmonic" if invProp and invMat else "standard"), + ("harmonic" if invert_model and invert_matrix else "standard"), ) - return discretize.tests.checkDerivative(fun, sig, num=5, plotIt=False) + return discretize.tests.check_derivative(fun, sig, num=5, plotIt=False) def test_FaceIP_1D_float(self): self.assertTrue(self.doTestFace([10], 0, False, "Tensor")) @@ -176,42 +176,42 @@ def test_EdgeIP_3D_anisotropic_fast(self): def test_FaceIP_1D_float_fast_harmonic(self): self.assertTrue( - self.doTestFace([10], 0, True, "Tensor", invProp=True, invMat=True) + self.doTestFace([10], 0, True, "Tensor", invert_model=True, invert_matrix=True) ) def test_FaceIP_2D_float_fast_harmonic(self): self.assertTrue( - self.doTestFace([10, 4], 0, True, "Tensor", invProp=True, invMat=True) + self.doTestFace([10, 4], 0, True, "Tensor", invert_model=True, invert_matrix=True) ) def test_FaceIP_3D_float_fast_harmonic(self): self.assertTrue( - self.doTestFace([10, 4, 5], 0, True, "Tensor", invProp=True, invMat=True) + self.doTestFace([10, 4, 5], 0, True, "Tensor", invert_model=True, invert_matrix=True) ) def test_FaceIP_1D_isotropic_fast_harmonic(self): self.assertTrue( - self.doTestFace([10], 1, True, "Tensor", invProp=True, invMat=True) + self.doTestFace([10], 1, True, "Tensor", invert_model=True, invert_matrix=True) ) def test_FaceIP_2D_isotropic_fast_harmonic(self): self.assertTrue( - self.doTestFace([10, 4], 1, True, "Tensor", invProp=True, invMat=True) + self.doTestFace([10, 4], 1, True, "Tensor", invert_model=True, invert_matrix=True) ) def test_FaceIP_3D_isotropic_fast_harmonic(self): self.assertTrue( - self.doTestFace([10, 4, 5], 1, True, "Tensor", invProp=True, invMat=True) + self.doTestFace([10, 4, 5], 1, True, "Tensor", invert_model=True, invert_matrix=True) ) def test_FaceIP_2D_anisotropic_fast_harmonic(self): self.assertTrue( - self.doTestFace([10, 4], 2, True, "Tensor", invProp=True, invMat=True) + self.doTestFace([10, 4], 2, True, "Tensor", invert_model=True, invert_matrix=True) ) def test_FaceIP_3D_anisotropic_fast_harmonic(self): self.assertTrue( - self.doTestFace([10, 4, 5], 3, True, "Tensor", invProp=True, invMat=True) + self.doTestFace([10, 4, 5], 3, True, "Tensor", invert_model=True, invert_matrix=True) ) def test_FaceIP_2D_float_Curv(self): diff --git a/tests/base/test_tensor_io.py b/tests/base/test_tensor_io.py index 28f161f7c..56799edae 100644 --- a/tests/base/test_tensor_io.py +++ b/tests/base/test_tensor_io.py @@ -30,10 +30,10 @@ def test_write_read_ubc_mesh_model_3d(self): modelfname = "arange.txt" modelfname1 = "arange2.txt" modeldict = {modelfname: vec, modelfname1: vec + 1} - mesh.writeUBC("temp.msh", modeldict, directory=self.basePath) - meshUBC = discretize.TensorMesh.readUBC(mshfname, directory=self.basePath) - vecUBC = meshUBC.readModelUBC(modelfname, directory=self.basePath) - vec2UBC = mesh.readModelUBC(modelfname1, directory=self.basePath) + mesh.write_UBC("temp.msh", modeldict, directory=self.basePath) + meshUBC = discretize.TensorMesh.read_UBC(mshfname, directory=self.basePath) + vecUBC = meshUBC.read_model_UBC(modelfname, directory=self.basePath) + vec2UBC = mesh.read_model_UBC(modelfname1, directory=self.basePath) # The mesh self.assertTrue(mesh.__str__() == meshUBC.__str__()) @@ -62,7 +62,7 @@ def test_VTKfiles(self): vtrfname = "temp.vtr" modelfname = "arange.txt" modeldict = {modelfname: vec} - mesh.writeVTK(vtrfname, modeldict, directory=self.basePath) + mesh.write_vtk(vtrfname, modeldict, directory=self.basePath) meshVTR, models = discretize.TensorMesh.read_vtk( vtrfname, directory=self.basePath ) @@ -118,7 +118,7 @@ def test_write_read_ubc_mesh_model_2d(self): # Write Mesh and model comment_lines = "!comment line\n" + "!again\n" + "!and again\n" - mesh.writeUBC( + mesh.write_UBC( fname, models=modeldict, directory=self.basePath, @@ -127,18 +127,18 @@ def test_write_read_ubc_mesh_model_2d(self): # Read back mesh and model fname = os.path.sep.join([self.basePath, "ubc_DC2D_tensor_mesh.msh"]) - mesh = discretize.TensorMesh.readUBC(fname) + mesh = discretize.TensorMesh.read_UBC(fname) modelfname = os.path.sep.join([self.basePath, "2d_2cyl_model"]) - readmodel = mesh.readModelUBC(modelfname) - self.assertTrue(mesh.nCx == 135) - self.assertTrue(mesh.nCy == 47) + readmodel = mesh.read_model_UBC(modelfname) + self.assertTrue(mesh.shape_cells[0] == 135) + self.assertTrue(mesh.shape_cells[1] == 47) # spot check a few things in the file - self.assertTrue(mesh.hx[0] == 2.84765625) + self.assertTrue(mesh.h[0][0] == 2.84765625) # The x0 is in a different place (-z) - self.assertTrue(mesh.x0[-1] == -np.sum(mesh.hy)) + self.assertTrue(mesh.x0[-1] == -np.sum(mesh.h[1])) # the z axis is flipped - self.assertTrue(mesh.hy[0] == 2.84765625) - self.assertTrue(mesh.hy[-1] == csz) + self.assertTrue(mesh.h[1][0] == 2.84765625) + self.assertTrue(mesh.h[1][-1] == csz) self.assertTrue(mesh.dim == 2) self.assertTrue(np.all(model == readmodel)) diff --git a/tests/base/test_tensor_omf.py b/tests/base/test_tensor_omf.py index 165c7c765..74a099e21 100644 --- a/tests/base/test_tensor_omf.py +++ b/tests/base/test_tensor_omf.py @@ -30,9 +30,9 @@ def test_to_omf(self): # Check geometry self.assertEqual(mesh.nC, geom.num_cells) self.assertEqual(mesh.nN, geom.num_nodes) - self.assertTrue(np.allclose(mesh.hx, geom.tensor_u)) - self.assertTrue(np.allclose(mesh.hy, geom.tensor_v)) - self.assertTrue(np.allclose(mesh.hz, geom.tensor_w)) + self.assertTrue(np.allclose(mesh.h[0], geom.tensor_u)) + self.assertTrue(np.allclose(mesh.h[1], geom.tensor_v)) + self.assertTrue(np.allclose(mesh.h[2], geom.tensor_w)) self.assertTrue(np.allclose(mesh.axis_u, geom.axis_u)) self.assertTrue(np.allclose(mesh.axis_v, geom.axis_v)) self.assertTrue(np.allclose(mesh.axis_w, geom.axis_w)) @@ -45,7 +45,7 @@ def test_to_omf(self): scalar_data = omf_element.data[i] self.assertEqual(name, scalar_data.name) arr = _unravel_data_array( - np.array(scalar_data.array), mesh.nCx, mesh.nCy, mesh.nCz + np.array(scalar_data.array), *mesh.shape_cells ) self.assertTrue(np.allclose(models[name], arr)) @@ -77,9 +77,9 @@ def test_from_omf(self): # Check geometry self.assertEqual(mesh.nC, geom.num_cells) self.assertEqual(mesh.nN, geom.num_nodes) - self.assertTrue(np.allclose(mesh.hx, geom.tensor_u)) - self.assertTrue(np.allclose(mesh.hy, geom.tensor_v)) - self.assertTrue(np.allclose(mesh.hz, geom.tensor_w)) + self.assertTrue(np.allclose(mesh.h[0], geom.tensor_u)) + self.assertTrue(np.allclose(mesh.h[1], geom.tensor_v)) + self.assertTrue(np.allclose(mesh.h[2], geom.tensor_w)) self.assertTrue(np.allclose(mesh.axis_u, geom.axis_u)) self.assertTrue(np.allclose(mesh.axis_v, geom.axis_v)) self.assertTrue(np.allclose(mesh.axis_w, geom.axis_w)) diff --git a/tests/base/test_utils.py b/tests/base/test_utils.py index 5ba47b318..565e7deea 100644 --- a/tests/base/test_utils.py +++ b/tests/base/test_utils.py @@ -6,24 +6,24 @@ sub2ind, ndgrid, mkvc, - isScalar, - inv2X2BlockDiagonal, - inv3X3BlockDiagonal, - invPropertyTensor, - makePropertyTensor, - indexCube, + is_scalar, + inverse_2x2_block_diagonal, + inverse_3x3_block_diagonal, + inverse_property_tensor, + make_property_tensor, + index_cube, ind2sub, - asArray_N_x_Dim, + as_array_n_by_dim, TensorType, Zero, Identity, - ExtractCoreMesh, + extract_core_mesh, active_from_xyz, mesh_builder_xyz, refine_tree_xyz, - meshTensor, + unpack_widths, ) -from discretize.tests import checkDerivative +from discretize.tests import check_derivative import discretize TOL = 1e-8 @@ -34,21 +34,21 @@ def test_simplePass(self): def simplePass(x): return np.sin(x), sdiag(np.cos(x)) - passed = checkDerivative(simplePass, np.random.randn(5), plotIt=False) + passed = check_derivative(simplePass, np.random.randn(5), plotIt=False) self.assertTrue(passed, True) def test_simpleFunction(self): def simpleFunction(x): return np.sin(x), lambda xi: sdiag(np.cos(x)) * xi - passed = checkDerivative(simpleFunction, np.random.randn(5), plotIt=False) + passed = check_derivative(simpleFunction, np.random.randn(5), plotIt=False) self.assertTrue(passed, True) def test_simpleFail(self): def simpleFail(x): return np.sin(x), -sdiag(np.cos(x)) - passed = checkDerivative(simpleFail, np.random.randn(5), plotIt=False) + passed = check_derivative(simpleFail, np.random.randn(5), plotIt=False) self.assertTrue(not passed, True) @@ -112,44 +112,44 @@ def test_ind2sub(self): self.assertTrue(np.all(ind2sub(x.shape, [0, 4, 5, 9])[0] == [0, 4, 0, 4])) self.assertTrue(np.all(ind2sub(x.shape, [0, 4, 5, 9])[1] == [0, 0, 1, 1])) - def test_indexCube_2D(self): + def test_index_cube_2D(self): nN = np.array([3, 3]) - self.assertTrue(np.all(indexCube("A", nN) == np.array([0, 1, 3, 4]))) - self.assertTrue(np.all(indexCube("B", nN) == np.array([3, 4, 6, 7]))) - self.assertTrue(np.all(indexCube("C", nN) == np.array([4, 5, 7, 8]))) - self.assertTrue(np.all(indexCube("D", nN) == np.array([1, 2, 4, 5]))) + self.assertTrue(np.all(index_cube("A", nN) == np.array([0, 1, 3, 4]))) + self.assertTrue(np.all(index_cube("B", nN) == np.array([3, 4, 6, 7]))) + self.assertTrue(np.all(index_cube("C", nN) == np.array([4, 5, 7, 8]))) + self.assertTrue(np.all(index_cube("D", nN) == np.array([1, 2, 4, 5]))) - def test_indexCube_3D(self): + def test_index_cube_3D(self): nN = np.array([3, 3, 3]) self.assertTrue( - np.all(indexCube("A", nN) == np.array([0, 1, 3, 4, 9, 10, 12, 13])) + np.all(index_cube("A", nN) == np.array([0, 1, 3, 4, 9, 10, 12, 13])) ) self.assertTrue( - np.all(indexCube("B", nN) == np.array([3, 4, 6, 7, 12, 13, 15, 16])) + np.all(index_cube("B", nN) == np.array([3, 4, 6, 7, 12, 13, 15, 16])) ) self.assertTrue( - np.all(indexCube("C", nN) == np.array([4, 5, 7, 8, 13, 14, 16, 17])) + np.all(index_cube("C", nN) == np.array([4, 5, 7, 8, 13, 14, 16, 17])) ) self.assertTrue( - np.all(indexCube("D", nN) == np.array([1, 2, 4, 5, 10, 11, 13, 14])) + np.all(index_cube("D", nN) == np.array([1, 2, 4, 5, 10, 11, 13, 14])) ) self.assertTrue( - np.all(indexCube("E", nN) == np.array([9, 10, 12, 13, 18, 19, 21, 22])) + np.all(index_cube("E", nN) == np.array([9, 10, 12, 13, 18, 19, 21, 22])) ) self.assertTrue( - np.all(indexCube("F", nN) == np.array([12, 13, 15, 16, 21, 22, 24, 25])) + np.all(index_cube("F", nN) == np.array([12, 13, 15, 16, 21, 22, 24, 25])) ) self.assertTrue( - np.all(indexCube("G", nN) == np.array([13, 14, 16, 17, 22, 23, 25, 26])) + np.all(index_cube("G", nN) == np.array([13, 14, 16, 17, 22, 23, 25, 26])) ) self.assertTrue( - np.all(indexCube("H", nN) == np.array([10, 11, 13, 14, 19, 20, 22, 23])) + np.all(index_cube("H", nN) == np.array([10, 11, 13, 14, 19, 20, 22, 23])) ) def test_invXXXBlockDiagonal(self): a = [np.random.rand(5, 1) for i in range(4)] - B = inv2X2BlockDiagonal(*a) + B = inverse_2x2_block_diagonal(*a) A = sp.vstack( ( @@ -162,7 +162,7 @@ def test_invXXXBlockDiagonal(self): self.assertTrue(np.linalg.norm(Z2.todense().ravel(), 2) < TOL) a = [np.random.rand(5, 1) for i in range(9)] - B = inv3X3BlockDiagonal(*a) + B = inverse_3x3_block_diagonal(*a) A = sp.vstack( ( @@ -176,7 +176,7 @@ def test_invXXXBlockDiagonal(self): self.assertTrue(np.linalg.norm(Z3.todense().ravel(), 2) < TOL) - def test_invPropertyTensor2D(self): + def test_inverse_property_tensor2D(self): M = discretize.TensorMesh([6, 6]) a1 = np.random.rand(M.nC) a2 = np.random.rand(M.nC) @@ -186,10 +186,10 @@ def test_invPropertyTensor2D(self): prop3 = np.c_[a1, a2, a3] for prop in [4, prop1, prop2, prop3]: - b = invPropertyTensor(M, prop) - A = makePropertyTensor(M, prop) - B1 = makePropertyTensor(M, b) - B2 = invPropertyTensor(M, prop, returnMatrix=True) + b = inverse_property_tensor(M, prop) + A = make_property_tensor(M, prop) + B1 = make_property_tensor(M, b) + B2 = inverse_property_tensor(M, prop, return_matrix=True) Z = B1 * A - sp.identity(M.nC * 2) self.assertTrue(np.linalg.norm(Z.todense().ravel(), 2) < TOL) @@ -229,7 +229,7 @@ def test_TensorType3D(self): self.assertRaises(Exception, TensorType, M, np.c_[a1, a2, a3, a3]) self.assertTrue(TensorType(M, None) == -1) - def test_invPropertyTensor3D(self): + def test_inverse_property_tensor3D(self): M = discretize.TensorMesh([6, 6, 6]) a1 = np.random.rand(M.nC) a2 = np.random.rand(M.nC) @@ -242,42 +242,42 @@ def test_invPropertyTensor3D(self): prop3 = np.c_[a1, a2, a3, a4, a5, a6] for prop in [4, prop1, prop2, prop3]: - b = invPropertyTensor(M, prop) - A = makePropertyTensor(M, prop) - B1 = makePropertyTensor(M, b) - B2 = invPropertyTensor(M, prop, returnMatrix=True) + b = inverse_property_tensor(M, prop) + A = make_property_tensor(M, prop) + B1 = make_property_tensor(M, b) + B2 = inverse_property_tensor(M, prop, return_matrix=True) Z = B1 * A - sp.identity(M.nC * 3) self.assertTrue(np.linalg.norm(Z.todense().ravel(), 2) < TOL) Z = B2 * A - sp.identity(M.nC * 3) self.assertTrue(np.linalg.norm(Z.todense().ravel(), 2) < TOL) - def test_isScalar(self): - self.assertTrue(isScalar(1.0)) - self.assertTrue(isScalar(1)) - self.assertTrue(isScalar(1j)) - self.assertTrue(isScalar(np.r_[1.0])) - self.assertTrue(isScalar(np.r_[1])) - self.assertTrue(isScalar(np.r_[1j])) + def test_is_scalar(self): + self.assertTrue(is_scalar(1.0)) + self.assertTrue(is_scalar(1)) + self.assertTrue(is_scalar(1j)) + self.assertTrue(is_scalar(np.r_[1.0])) + self.assertTrue(is_scalar(np.r_[1])) + self.assertTrue(is_scalar(np.r_[1j])) - def test_asArray_N_x_Dim(self): + def test_as_array_n_by_dim(self): true = np.array([[1, 2, 3]]) - listArray = asArray_N_x_Dim([1, 2, 3], 3) + listArray = as_array_n_by_dim([1, 2, 3], 3) self.assertTrue(np.all(true == listArray)) self.assertTrue(true.shape == listArray.shape) - listArray = asArray_N_x_Dim(np.r_[1, 2, 3], 3) + listArray = as_array_n_by_dim(np.r_[1, 2, 3], 3) self.assertTrue(np.all(true == listArray)) self.assertTrue(true.shape == listArray.shape) - listArray = asArray_N_x_Dim(np.array([[1, 2, 3.0]]), 3) + listArray = as_array_n_by_dim(np.array([[1, 2, 3.0]]), 3) self.assertTrue(np.all(true == listArray)) self.assertTrue(true.shape == listArray.shape) true = np.array([[1, 2], [4, 5]]) - listArray = asArray_N_x_Dim([[1, 2], [4, 5]], 2) + listArray = as_array_n_by_dim([[1, 2], [4, 5]], 2) self.assertTrue(np.all(true == listArray)) self.assertTrue(true.shape == listArray.shape) @@ -429,42 +429,42 @@ def test_both(self): class TestMeshUtils(unittest.TestCase): - def test_ExtractCoreMesh(self): + def test_extract_core_mesh(self): # 1D Test on TensorMesh meshtest1d = discretize.TensorMesh([[(50.0, 10)]]) xzlim1d = np.r_[[[0.0, 250.0]]] - actind1d, meshCore1d = ExtractCoreMesh(xzlim1d, meshtest1d) + actind1d, meshCore1d = extract_core_mesh(xzlim1d, meshtest1d) self.assertEqual(len(actind1d), meshtest1d.nC) self.assertEqual(meshCore1d.nC, np.count_nonzero(actind1d)) - self.assertGreater(meshCore1d.vectorCCx.min(), xzlim1d[0, :].min()) - self.assertLess(meshCore1d.vectorCCx.max(), xzlim1d[0, :].max()) + self.assertGreater(meshCore1d.cell_centers_x.min(), xzlim1d[0, :].min()) + self.assertLess(meshCore1d.cell_centers_x.max(), xzlim1d[0, :].max()) # 2D Test on TensorMesh meshtest2d = discretize.TensorMesh([[(50.0, 10)], [(25.0, 10)]]) xzlim2d = np.r_[[[0.0, 200.0], [0.0, 200.0]]] - actind2d, meshCore2d = ExtractCoreMesh(xzlim2d, meshtest2d) + actind2d, meshCore2d = extract_core_mesh(xzlim2d, meshtest2d) self.assertEqual(len(actind2d), meshtest2d.nC) self.assertEqual(meshCore2d.nC, np.count_nonzero(actind2d)) - self.assertGreater(meshCore2d.vectorCCx.min(), xzlim2d[0, :].min()) - self.assertLess(meshCore2d.vectorCCx.max(), xzlim2d[0, :].max()) - self.assertGreater(meshCore2d.vectorCCy.min(), xzlim2d[1, :].min()) - self.assertLess(meshCore2d.vectorCCy.max(), xzlim2d[1, :].max()) + self.assertGreater(meshCore2d.cell_centers_x.min(), xzlim2d[0, :].min()) + self.assertLess(meshCore2d.cell_centers_x.max(), xzlim2d[0, :].max()) + self.assertGreater(meshCore2d.cell_centers_y.min(), xzlim2d[1, :].min()) + self.assertLess(meshCore2d.cell_centers_y.max(), xzlim2d[1, :].max()) # 3D Test on TensorMesh meshtest3d = discretize.TensorMesh([[(50.0, 10)], [(25.0, 10)], [(5.0, 40)]]) xzlim3d = np.r_[[[0.0, 250.0], [0.0, 200.0], [0.0, 150]]] - actind3d, meshCore3d = ExtractCoreMesh(xzlim3d, meshtest3d) + actind3d, meshCore3d = extract_core_mesh(xzlim3d, meshtest3d) self.assertEqual(len(actind3d), meshtest3d.nC) self.assertEqual(meshCore3d.nC, np.count_nonzero(actind3d)) - self.assertGreater(meshCore3d.vectorCCx.min(), xzlim3d[0, :].min()) - self.assertLess(meshCore3d.vectorCCx.max(), xzlim3d[0, :].max()) - self.assertGreater(meshCore3d.vectorCCy.min(), xzlim3d[1, :].min()) - self.assertLess(meshCore3d.vectorCCy.max(), xzlim3d[1, :].max()) - self.assertGreater(meshCore3d.vectorCCz.min(), xzlim3d[2, :].min()) - self.assertLess(meshCore3d.vectorCCz.max(), xzlim3d[2, :].max()) + self.assertGreater(meshCore3d.cell_centers_x.min(), xzlim3d[0, :].min()) + self.assertLess(meshCore3d.cell_centers_x.max(), xzlim3d[0, :].max()) + self.assertGreater(meshCore3d.cell_centers_y.min(), xzlim3d[1, :].min()) + self.assertLess(meshCore3d.cell_centers_y.max(), xzlim3d[1, :].max()) + self.assertGreater(meshCore3d.cell_centers_z.min(), xzlim3d[2, :].min()) + self.assertLess(meshCore3d.cell_centers_z.max(), xzlim3d[2, :].max()) def test_active_from_xyz(self): # Create 3D topo @@ -604,7 +604,7 @@ def test_active_from_xyz(self): hz = [(dz, npad_z, -exp_z), (dz, ncz), (dz, npad_z, exp_z)] # A value of 1 is used to define the discretization in phi for this case. - mesh_cyl = discretize.CylMesh([hr, 1, hz], x0="00C") + mesh_cyl = discretize.CylindricalMesh([hr, 1, hz], x0="00C") indtopoCC = active_from_xyz( mesh_cyl, topo3D, grid_reference="CC", method="nearest" @@ -616,10 +616,10 @@ def test_active_from_xyz(self): self.assertEqual(indtopoCC.sum(), 183) self.assertEqual(indtopoN.sum(), 171) - htheta = meshTensor([(1.0, 4)]) + htheta = unpack_widths([(1.0, 4)]) htheta = htheta * 2 * np.pi / htheta.sum() - mesh_cyl2 = discretize.CylMesh([hr, htheta, hz], x0="00C") + mesh_cyl2 = discretize.CylindricalMesh([hr, htheta, hz], x0="00C") with self.assertRaises(NotImplementedError): indtopoCC = active_from_xyz( mesh_cyl2, topo3D, grid_reference="CC", method="nearest" diff --git a/tests/base/test_view.py b/tests/base/test_view.py index 702f5e10c..8134870fe 100644 --- a/tests/base/test_view.py +++ b/tests/base/test_view.py @@ -13,44 +13,44 @@ class Cyl3DView(unittest.TestCase): def setUp(self): - self.mesh = discretize.CylMesh([10, 4, 12]) + self.mesh = discretize.CylindricalMesh([10, 4, 12]) def test_incorrectAxesWarnings(self): # axes aren't polar fig, ax = plt.subplots(1, 1) # test z-slice with pytest.warns(UserWarning): - self.mesh.plotGrid(slice="z", ax=ax) + self.mesh.plot_grid(slice="z", ax=ax) # axes aren't right shape with pytest.warns(UserWarning): - self.mesh.plotGrid(slice="both", ax=ax) - self.mesh.plotGrid(ax=ax) + self.mesh.plot_grid(slice="both", ax=ax) + self.mesh.plot_grid(ax=ax) # this should be fine - self.mesh.plotGrid(slice="theta", ax=ax) + self.mesh.plot_grid(slice="theta", ax=ax) fig, ax = plt.subplots(2, 1) # axes are right shape, but not polar with pytest.warns(UserWarning): - self.mesh.plotGrid(slice="both", ax=ax) - self.mesh.plotGrid(ax=ax) + self.mesh.plot_grid(slice="both", ax=ax) + self.mesh.plot_grid(ax=ax) # these should be fine - self.mesh.plotGrid() + self.mesh.plot_grid() ax0 = plt.subplot(121, projection="polar") ax1 = plt.subplot(122) - self.mesh.plotGrid(slice="z", ax=ax0) # plot z only - self.mesh.plotGrid(slice="theta", ax=ax1) # plot theta only - self.mesh.plotGrid(slice="both", ax=[ax0, ax1]) # plot both - self.mesh.plotGrid(slice="both", ax=[ax1, ax0]) # plot both - self.mesh.plotGrid(ax=[ax1, ax0]) # plot both + self.mesh.plot_grid(slice="z", ax=ax0) # plot z only + self.mesh.plot_grid(slice="theta", ax=ax1) # plot theta only + self.mesh.plot_grid(slice="both", ax=[ax0, ax1]) # plot both + self.mesh.plot_grid(slice="both", ax=[ax1, ax0]) # plot both + self.mesh.plot_grid(ax=[ax1, ax0]) # plot both - def test_plotImage(self): + def test_plot_image(self): with self.assertRaises(NotImplementedError): - self.mesh.plotImage(np.random.rand(self.mesh.nC)) + self.mesh.plot_image(np.random.rand(self.mesh.nC)) if __name__ == "__main__": diff --git a/tests/base/test_volume_avg.py b/tests/base/test_volume_avg.py index 1d0ff8d90..ed319bf9e 100644 --- a/tests/base/test_volume_avg.py +++ b/tests/base/test_volume_avg.py @@ -34,8 +34,8 @@ def test_tensor_to_tensor(self): out3 = Av @ in_put assert_allclose(out1, out3) - vol1 = np.sum(mesh1.vol * in_put) - vol2 = np.sum(mesh2.vol * out3) + vol1 = np.sum(mesh1.cell_volumes * in_put) + vol2 = np.sum(mesh2.cell_volumes * out3) print(vol1, vol2) self.assertAlmostEqual(vol1, vol2) @@ -73,8 +73,8 @@ def test_tree_to_tree(self): out3 = Av @ in_put assert_allclose(out1, out3) - vol1 = np.sum(mesh1.vol * in_put) - vol2 = np.sum(mesh2.vol * out3) + vol1 = np.sum(mesh1.cell_volumes * in_put) + vol2 = np.sum(mesh2.cell_volumes * out3) print(vol1, vol2) self.assertAlmostEqual(vol1, vol2) @@ -109,8 +109,8 @@ def test_tree_to_tensor(self): out3 = Av @ in_put assert_allclose(out1, out3) - vol1 = np.sum(mesh1.vol * in_put) - vol2 = np.sum(mesh2.vol * out3) + vol1 = np.sum(mesh1.cell_volumes * in_put) + vol2 = np.sum(mesh2.cell_volumes * out3) print(vol1, vol2) self.assertAlmostEqual(vol1, vol2) @@ -145,8 +145,8 @@ def test_tensor_to_tree(self): out3 = Av @ in_put assert_allclose(out1, out3) - vol1 = np.sum(mesh1.vol * in_put) - vol2 = np.sum(mesh2.vol * out3) + vol1 = np.sum(mesh1.cell_volumes * in_put) + vol2 = np.sum(mesh2.cell_volumes * out3) print(vol1, vol2) self.assertAlmostEqual(vol1, vol2) @@ -161,7 +161,7 @@ def test_errors(self): hr = np.r_[1, 1, 0.5] hz = np.r_[2, 1] - meshCyl = discretize.CylMesh([hr, 1, hz], np.r_[0.0, 0.0, 0.0]) + meshCyl = discretize.CylindricalMesh([hr, 1, hz], np.r_[0.0, 0.0, 0.0]) mesh2 = discretize.TreeMesh([h2, h2]) mesh2.insert_cells([0.75, 0.75], [4]) @@ -214,8 +214,8 @@ def test_tree_to_tree_same_base(self): out3 = Av @ in_put assert_allclose(out1, out3) - vol1 = np.sum(mesh1.vol * in_put) - vol2 = np.sum(mesh2.vol * out3) + vol1 = np.sum(mesh1.cell_volumes * in_put) + vol2 = np.sum(mesh2.cell_volumes * out3) print(vol1, vol2) self.assertAlmostEqual(vol1, vol2) @@ -246,8 +246,8 @@ def test_tree_to_tensor_same_base(self): out3 = Av @ in_put assert_allclose(out1, out3) - vol1 = np.sum(mesh1.vol * in_put) - vol2 = np.sum(mesh2.vol * out3) + vol1 = np.sum(mesh1.cell_volumes * in_put) + vol2 = np.sum(mesh2.cell_volumes * out3) print(vol1, vol2) self.assertAlmostEqual(vol1, vol2) @@ -278,8 +278,8 @@ def test_tensor_to_tree_same_base(self): out3 = Av @ in_put assert_allclose(out1, out3) - vol1 = np.sum(mesh1.vol * in_put) - vol2 = np.sum(mesh2.vol * out3) + vol1 = np.sum(mesh1.cell_volumes * in_put) + vol2 = np.sum(mesh2.cell_volumes * out3) print(vol1, vol2) self.assertAlmostEqual(vol1, vol2) @@ -314,8 +314,8 @@ def test_tensor_to_tensor_sub(self): if i > 0: cells = np.all(cells, axis=1) - vol1 = np.sum(mesh1.vol[cells] * in_put[cells]) - vol2 = np.sum(mesh2.vol * out3) + vol1 = np.sum(mesh1.cell_volumes[cells] * in_put[cells]) + vol2 = np.sum(mesh2.cell_volumes * out3) print(vol1, vol2) self.assertAlmostEqual(vol1, vol2) @@ -356,8 +356,8 @@ def test_tree_to_tree_sub(self): if i > 0: cells = np.all(cells, axis=1) - vol1 = np.sum(mesh1.vol[cells] * in_put[cells]) - vol2 = np.sum(mesh2.vol * out3) + vol1 = np.sum(mesh1.cell_volumes[cells] * in_put[cells]) + vol2 = np.sum(mesh2.cell_volumes * out3) print(vol1, vol2) self.assertAlmostEqual(vol1, vol2) @@ -395,8 +395,8 @@ def test_tree_to_tensor_sub(self): if i > 0: cells = np.all(cells, axis=1) - vol1 = np.sum(mesh1.vol[cells] * in_put[cells]) - vol2 = np.sum(mesh2.vol * out3) + vol1 = np.sum(mesh1.cell_volumes[cells] * in_put[cells]) + vol2 = np.sum(mesh2.cell_volumes * out3) print(vol1, vol2) self.assertAlmostEqual(vol1, vol2) @@ -434,8 +434,8 @@ def test_tensor_to_tree_sub(self): if i > 0: cells = np.all(cells, axis=1) - vol1 = np.sum(mesh1.vol[cells] * in_put[cells]) - vol2 = np.sum(mesh2.vol * out3) + vol1 = np.sum(mesh1.cell_volumes[cells] * in_put[cells]) + vol2 = np.sum(mesh2.cell_volumes * out3) print(vol1, vol2) self.assertAlmostEqual(vol1, vol2) diff --git a/tests/boundaries/test_tensor_boundary.py b/tests/boundaries/test_tensor_boundary.py index cb10be1a0..c32a55bac 100644 --- a/tests/boundaries/test_tensor_boundary.py +++ b/tests/boundaries/test_tensor_boundary.py @@ -24,13 +24,13 @@ def getxBCyBC_CC(mesh, alpha, beta, gamma): if mesh.dim == 1: # 1D if len(alpha) != 2 or len(beta) != 2 or len(gamma) != 2: raise Exception("Lenght of list, alpha should be 2") - mesh.cellBoundaryInd + mesh.cell_boundary_indices alpha_xm, beta_xm, gamma_xm = alpha[0], beta[0], gamma[0] alpha_xp, beta_xp, gamma_xp = alpha[1], beta[1], gamma[1] # h_xm, h_xp = mesh.gridCC[fCCxm], mesh.gridCC[fCCxp] - h_xm, h_xp = mesh.hx[0], mesh.hx[-1] + h_xm, h_xp = mesh.h[0][0], mesh.h[0][-1] a_xm = gamma_xm / (0.5 * alpha_xm - beta_xm / h_xm) b_xm = (0.5 * alpha_xm + beta_xm / h_xm) / (0.5 * alpha_xm - beta_xm / h_xm) @@ -49,7 +49,7 @@ def getxBCyBC_CC(mesh, alpha, beta, gamma): if len(alpha) != 4 or len(beta) != 4 or len(gamma) != 4: raise Exception("Lenght of list, alpha should be 4") - fxm, fxp, fym, fyp = mesh.faceBoundaryInd + fxm, fxp, fym, fyp = mesh.face_boundary_indices alpha_xm, beta_xm, gamma_xm = alpha[0], beta[0], gamma[0] alpha_xp, beta_xp, gamma_xp = alpha[1], beta[1], gamma[1] @@ -59,10 +59,10 @@ def getxBCyBC_CC(mesh, alpha, beta, gamma): # h_xm, h_xp = mesh.gridCC[fCCxm,0], mesh.gridCC[fCCxp,0] # h_ym, h_yp = mesh.gridCC[fCCym,1], mesh.gridCC[fCCyp,1] - h_xm = mesh.hx[0] * np.ones_like(alpha_xm) - h_xp = mesh.hx[-1] * np.ones_like(alpha_xp) - h_ym = mesh.hy[0] * np.ones_like(alpha_ym) - h_yp = mesh.hy[-1] * np.ones_like(alpha_yp) + h_xm = mesh.h[0][0] * np.ones_like(alpha_xm) + h_xp = mesh.h[0][-1] * np.ones_like(alpha_xp) + h_ym = mesh.h[1][0] * np.ones_like(alpha_ym) + h_yp = mesh.h[1][-1] * np.ones_like(alpha_yp) a_xm = gamma_xm / (0.5 * alpha_xm - beta_xm / h_xm) b_xm = (0.5 * alpha_xm + beta_xm / h_xm) / (0.5 * alpha_xm - beta_xm / h_xm) @@ -101,8 +101,8 @@ def getxBCyBC_CC(mesh, alpha, beta, gamma): elif mesh.dim == 3: # 3D if len(alpha) != 6 or len(beta) != 6 or len(gamma) != 6: raise Exception("Lenght of list, alpha should be 6") - # fCCxm,fCCxp,fCCym,fCCyp,fCCzm,fCCzp = mesh.cellBoundaryInd - fxm, fxp, fym, fyp, fzm, fzp = mesh.faceBoundaryInd + # fCCxm,fCCxp,fCCym,fCCyp,fCCzm,fCCzp = mesh.cell_boundary_indices + fxm, fxp, fym, fyp, fzm, fzp = mesh.face_boundary_indices alpha_xm, beta_xm, gamma_xm = alpha[0], beta[0], gamma[0] alpha_xp, beta_xp, gamma_xp = alpha[1], beta[1], gamma[1] @@ -115,12 +115,12 @@ def getxBCyBC_CC(mesh, alpha, beta, gamma): # h_ym, h_yp = mesh.gridCC[fCCym,1], mesh.gridCC[fCCyp,1] # h_zm, h_zp = mesh.gridCC[fCCzm,2], mesh.gridCC[fCCzp,2] - h_xm = mesh.hx[0] * np.ones_like(alpha_xm) - h_xp = mesh.hx[-1] * np.ones_like(alpha_xp) - h_ym = mesh.hy[0] * np.ones_like(alpha_ym) - h_yp = mesh.hy[-1] * np.ones_like(alpha_yp) - h_zm = mesh.hz[0] * np.ones_like(alpha_zm) - h_zp = mesh.hz[-1] * np.ones_like(alpha_zp) + h_xm = mesh.h[0][0] * np.ones_like(alpha_xm) + h_xp = mesh.h[0][-1] * np.ones_like(alpha_xp) + h_ym = mesh.h[1][0] * np.ones_like(alpha_ym) + h_yp = mesh.h[1][-1] * np.ones_like(alpha_yp) + h_zm = mesh.h[2][0] * np.ones_like(alpha_zm) + h_zp = mesh.h[2][-1] * np.ones_like(alpha_zp) a_xm = gamma_xm / (0.5 * alpha_xm - beta_xm / h_xm) b_xm = (0.5 * alpha_xm + beta_xm / h_xm) / (0.5 * alpha_xm - beta_xm / h_xm) @@ -198,7 +198,7 @@ def q_fun(x): xc_ana = phi_fun(self.M.gridCC) # Get boundary locations - vecN = self.M.vectorNx + vecN = self.M.nodes_x # Setup Mixed B.C (alpha, beta, gamma) alpha_xm, alpha_xp = 1.0, 1.0 @@ -211,11 +211,11 @@ def q_fun(x): x_BC, y_BC = getxBCyBC_CC(self.M, alpha, beta, gamma) sigma = np.ones(self.M.nC) - self.M.getFaceInnerProduct(1.0 / sigma) - MfrhoI = self.M.getFaceInnerProduct(1.0 / sigma, invMat=True) - V = discretize.utils.sdiag(self.M.vol) - Div = V * self.M.faceDiv - P_BC, B = self.M.getBCProjWF_simple() + self.M.get_face_inner_product(1.0 / sigma) + MfrhoI = self.M.get_face_inner_product(1.0 / sigma, invert_matrix=True) + V = discretize.utils.sdiag(self.M.cell_volumes) + Div = V * self.M.face_divergence + P_BC, B = self.M.get_BC_projections_simple() q = q_fun(self.M.gridCC) M = B * self.M.aveCC2F G = Div.T - P_BC * discretize.utils.sdiag(y_BC) * M @@ -269,7 +269,7 @@ def q_fun(x): xc_ana = phi_fun(self.M.gridCC) # Get boundary locations - fxm, fxp, fym, fyp = self.M.faceBoundaryInd + fxm, fxp, fym, fyp = self.M.face_boundary_indices gBFxm = self.M.gridFx[fxm, :] gBFxp = self.M.gridFx[fxp, :] gBFym = self.M.gridFy[fym, :] @@ -308,11 +308,11 @@ def gamma_fun(alpha, beta, phi, phi_deriv): x_BC, y_BC = getxBCyBC_CC(self.M, alpha, beta, gamma) sigma = np.ones(self.M.nC) - self.M.getFaceInnerProduct(1.0 / sigma) - MfrhoI = self.M.getFaceInnerProduct(1.0 / sigma, invMat=True) - V = discretize.utils.sdiag(self.M.vol) - Div = V * self.M.faceDiv - P_BC, B = self.M.getBCProjWF_simple() + self.M.get_face_inner_product(1.0 / sigma) + MfrhoI = self.M.get_face_inner_product(1.0 / sigma, invert_matrix=True) + V = discretize.utils.sdiag(self.M.cell_volumes) + Div = V * self.M.face_divergence + P_BC, B = self.M.get_BC_projections_simple() q = q_fun(self.M.gridCC) M = B * self.M.aveCC2F G = Div.T - P_BC * discretize.utils.sdiag(y_BC) * M @@ -389,7 +389,7 @@ def q_fun(x): xc_ana = phi_fun(self.M.gridCC) # Get boundary locations - fxm, fxp, fym, fyp, fzm, fzp = self.M.faceBoundaryInd + fxm, fxp, fym, fyp, fzm, fzp = self.M.face_boundary_indices gBFxm = self.M.gridFx[fxm, :] gBFxp = self.M.gridFx[fxp, :] gBFym = self.M.gridFy[fym, :] @@ -439,11 +439,11 @@ def gamma_fun(alpha, beta, phi, phi_deriv): x_BC, y_BC = getxBCyBC_CC(self.M, alpha, beta, gamma) sigma = np.ones(self.M.nC) - self.M.getFaceInnerProduct(1.0 / sigma) - MfrhoI = self.M.getFaceInnerProduct(1.0 / sigma, invMat=True) - V = discretize.utils.sdiag(self.M.vol) - Div = V * self.M.faceDiv - P_BC, B = self.M.getBCProjWF_simple() + self.M.get_face_inner_product(1.0 / sigma) + MfrhoI = self.M.get_face_inner_product(1.0 / sigma, invert_matrix=True) + V = discretize.utils.sdiag(self.M.cell_volumes) + Div = V * self.M.face_divergence + P_BC, B = self.M.get_BC_projections_simple() q = q_fun(self.M.gridCC) M = B * self.M.aveCC2F G = Div.T - P_BC * discretize.utils.sdiag(y_BC) * M diff --git a/tests/boundaries/test_tensor_boundary_poisson.py b/tests/boundaries/test_tensor_boundary_poisson.py index 71c939e0a..a892f2bc3 100644 --- a/tests/boundaries/test_tensor_boundary_poisson.py +++ b/tests/boundaries/test_tensor_boundary_poisson.py @@ -27,19 +27,19 @@ def getError(self): j_ana = j_fun(self.M.gridFx) # TODO: Check where our boundary conditions are CCx or Nx - # vec = self.M.vectorNx - vec = self.M.vectorCCx + # vec = self.M.nodes_x + vec = self.M.cell_centers_x phi_bc = phi(vec[[0, -1]]) j_bc = j_fun(vec[[0, -1]]) - P, Pin, Pout = self.M.getBCProjWF([["dirichlet", "dirichlet"]]) + P, Pin, Pout = self.M.get_BC_projections([["dirichlet", "dirichlet"]]) - Mc = self.M.getFaceInnerProduct() - McI = utils.sdInv(Mc) - V = utils.sdiag(self.M.vol) - G = -Pin.T * Pin * self.M.faceDiv.T * V - D = self.M.faceDiv + Mc = self.M.get_face_inner_product() + McI = utils.sdinv(Mc) + V = utils.sdiag(self.M.cell_volumes) + G = -Pin.T * Pin * self.M.face_divergence.T * V + D = self.M.face_divergence j = McI * (G * xc_ana + P * phi_bc) q = D * Pin.T * Pin * j + D * Pout.T * j_bc @@ -110,10 +110,10 @@ def getError(self): j_ana = np.r_[jX_ana, jY_ana] # TODO: Check where our boundary conditions are CCx or Nx - # fxm,fxp,fym,fyp = self.M.faceBoundaryInd + # fxm,fxp,fym,fyp = self.M.face_boundary_indices # gBFx = self.M.gridFx[(fxm|fxp),:] # gBFy = self.M.gridFy[(fym|fyp),:] - fxm, fxp, fym, fyp = self.M.cellBoundaryInd + fxm, fxp, fym, fyp = self.M.cell_boundary_indices gBFx = self.M.gridCC[(fxm | fxp), :] gBFy = self.M.gridCC[(fym | fyp), :] @@ -121,16 +121,16 @@ def getError(self): # P = sp.csr_matrix(([-1,1],([0,self.M.nF-1],[0,1])), shape=(self.M.nF, 2)) - P, Pin, Pout = self.M.getBCProjWF("dirichlet") + P, Pin, Pout = self.M.get_BC_projections("dirichlet") - Mc = self.M.getFaceInnerProduct() - McI = utils.sdInv(Mc) - G = -self.M.faceDiv.T * utils.sdiag(self.M.vol) - D = self.M.faceDiv + Mc = self.M.get_face_inner_product() + McI = utils.sdinv(Mc) + G = -self.M.face_divergence.T * utils.sdiag(self.M.cell_volumes) + D = self.M.face_divergence j = McI * (G * xc_ana + P * bc) q = D * j - # self.M.plotImage(j, 'FxFy', show_it=True) + # self.M.plot_image(j, 'FxFy', show_it=True) # Rearrange if we know q to solve for x A = D * McI * G @@ -189,19 +189,19 @@ def getError(self): j_ana = j_fun(self.M.gridFx) # TODO: Check where our boundary conditions are CCx or Nx - vecN = self.M.vectorNx - vecC = self.M.vectorCCx + vecN = self.M.nodes_x + vecC = self.M.cell_centers_x phi_bc = phi(vecC[[0, -1]]) j_bc = j_fun(vecN[[0, -1]]) - P, Pin, Pout = self.M.getBCProjWF([["neumann", "neumann"]]) + P, Pin, Pout = self.M.get_BC_projections([["neumann", "neumann"]]) - Mc = self.M.getFaceInnerProduct() - McI = utils.sdInv(Mc) - V = utils.sdiag(self.M.vol) - G = -Pin.T * Pin * self.M.faceDiv.T * V - D = self.M.faceDiv + Mc = self.M.get_face_inner_product() + McI = utils.sdinv(Mc) + V = utils.sdiag(self.M.cell_volumes) + G = -Pin.T * Pin * self.M.face_divergence.T * V + D = self.M.face_divergence j = McI * (G * xc_ana + P * phi_bc) q = V * D * Pin.T * Pin * j + V * D * Pout.T * j_bc @@ -271,8 +271,8 @@ def getError(self): # TODO: Check where our boundary conditions are CCx or Nx - cxm, cxp, cym, cyp = self.M.cellBoundaryInd - fxm, fxp, fym, fyp = self.M.faceBoundaryInd + cxm, cxp, cym, cyp = self.M.cell_boundary_indices + fxm, fxp, fym, fyp = self.M.face_boundary_indices gBFx = self.M.gridFx[(fxm | fxp), :] gBFy = self.M.gridFy[(fym | fyp), :] @@ -282,13 +282,13 @@ def getError(self): # P = sp.csr_matrix(([-1,1],([0,self.M.nF-1],[0,1])), shape=(self.M.nF, 2)) - P, Pin, Pout = self.M.getBCProjWF("neumann") + P, Pin, Pout = self.M.get_BC_projections("neumann") - Mc = self.M.getFaceInnerProduct() - McI = utils.sdInv(Mc) - V = utils.sdiag(self.M.vol) - G = -Pin.T * Pin * self.M.faceDiv.T * V - D = self.M.faceDiv + Mc = self.M.get_face_inner_product() + McI = utils.sdinv(Mc) + V = utils.sdiag(self.M.cell_volumes) + G = -Pin.T * Pin * self.M.face_divergence.T * V + D = self.M.face_divergence j = McI * (G * xc_ana + P * phi_bc) q = V * D * Pin.T * Pin * j + V * D * Pout.T * j_bc @@ -351,19 +351,19 @@ def getError(self): j_ana = j_fun(self.M.gridFx) # TODO: Check where our boundary conditions are CCx or Nx - vecN = self.M.vectorNx - vecC = self.M.vectorCCx + vecN = self.M.nodes_x + vecC = self.M.cell_centers_x phi_bc = phi(vecC[[0, -1]]) j_bc = j_fun(vecN[[0, -1]]) - P, Pin, Pout = self.M.getBCProjWF([["dirichlet", "neumann"]]) + P, Pin, Pout = self.M.get_BC_projections([["dirichlet", "neumann"]]) - Mc = self.M.getFaceInnerProduct() - McI = utils.sdInv(Mc) - V = utils.sdiag(self.M.vol) - G = -Pin.T * Pin * self.M.faceDiv.T * V - D = self.M.faceDiv + Mc = self.M.get_face_inner_product() + McI = utils.sdinv(Mc) + V = utils.sdiag(self.M.cell_volumes) + G = -Pin.T * Pin * self.M.face_divergence.T * V + D = self.M.face_divergence j = McI * (G * xc_ana + P * phi_bc) q = V * D * Pin.T * Pin * j + V * D * Pout.T * j_bc @@ -443,8 +443,8 @@ def getError(self): # TODO: Check where our boundary conditions are CCx or Nx - cxm, cxp, cym, cyp = self.M.cellBoundaryInd - fxm, fxp, fym, fyp = self.M.faceBoundaryInd + cxm, cxp, cym, cyp = self.M.cell_boundary_indices + fxm, fxp, fym, fyp = self.M.face_boundary_indices gBFx = self.M.gridFx[(fxm | fxp), :] gBFy = self.M.gridFy[(fym | fyp), :] @@ -457,15 +457,15 @@ def getError(self): # P = sp.csr_matrix(([-1,1],([0,self.M.nF-1],[0,1])), shape=(self.M.nF, 2)) - P, Pin, Pout = self.M.getBCProjWF( + P, Pin, Pout = self.M.get_BC_projections( [["dirichlet", "neumann"], ["dirichlet", "neumann"]] ) - Mc = self.M.getFaceInnerProduct() - McI = utils.sdInv(Mc) - V = utils.sdiag(self.M.vol) - G = -Pin.T * Pin * self.M.faceDiv.T * V - D = self.M.faceDiv + Mc = self.M.get_face_inner_product() + McI = utils.sdinv(Mc) + V = utils.sdiag(self.M.cell_volumes) + G = -Pin.T * Pin * self.M.face_divergence.T * V + D = self.M.face_divergence j = McI * (G * xc_ana + P * phi_bc) q = V * D * Pin.T * Pin * j + V * D * Pout.T * j_bc diff --git a/tests/cyl/test_cyl.py b/tests/cyl/test_cyl.py index 60de9236f..09d76641a 100644 --- a/tests/cyl/test_cyl.py +++ b/tests/cyl/test_cyl.py @@ -11,23 +11,23 @@ class TestCylSymmetricMesh(unittest.TestCase): def setUp(self): hx = np.r_[1, 1, 0.5] hz = np.r_[2, 1] - self.mesh = discretize.CylMesh([hx, 1, hz], np.r_[0.0, 0.0, 0.0]) + self.mesh = discretize.CylindricalMesh([hx, 1, hz], np.r_[0.0, 0.0, 0.0]) def test_dim(self): self.assertEqual(self.mesh.dim, 3) def test_nC(self): self.assertEqual(self.mesh.nC, 6) - self.assertEqual(self.mesh.nCx, 3) - self.assertEqual(self.mesh.nCy, 1) - self.assertEqual(self.mesh.nCz, 2) + self.assertEqual(self.mesh.shape_cells[0], 3) + self.assertEqual(self.mesh.shape_cells[1], 1) + self.assertEqual(self.mesh.shape_cells[2], 2) self.assertEqual(self.mesh.vnC, (3, 1, 2)) def test_nN(self): self.assertEqual(self.mesh.nN, 0) - self.assertEqual(self.mesh.nNx, 3) - self.assertEqual(self.mesh.nNy, 0) - self.assertEqual(self.mesh.nNz, 3) + self.assertEqual(self.mesh.shape_nodes[0], 3) + self.assertEqual(self.mesh.shape_nodes[1], 0) + self.assertEqual(self.mesh.shape_nodes[2], 3) self.assertEqual(self.mesh.vnN, (3, 0, 3)) def test_nF(self): @@ -52,23 +52,23 @@ def test_nE(self): def test_vectorsCC(self): v = np.r_[0.5, 1.5, 2.25] - self.assertEqual(np.linalg.norm((v - self.mesh.vectorCCx)), 0) + self.assertEqual(np.linalg.norm((v - self.mesh.cell_centers_x)), 0) v = np.r_[0] - self.assertEqual(np.linalg.norm((v - self.mesh.vectorCCy)), 0) + self.assertEqual(np.linalg.norm((v - self.mesh.cell_centers_y)), 0) v = np.r_[1, 2.5] - self.assertEqual(np.linalg.norm((v - self.mesh.vectorCCz)), 0) + self.assertEqual(np.linalg.norm((v - self.mesh.cell_centers_z)), 0) def test_vectorsN(self): v = np.r_[1, 2, 2.5] - self.assertEqual(np.linalg.norm((v - self.mesh.vectorNx)), 0) + self.assertEqual(np.linalg.norm((v - self.mesh.nodes_x)), 0) v = np.r_[0] - self.assertEqual(np.linalg.norm((v - self.mesh.vectorNy)), 0) + self.assertEqual(np.linalg.norm((v - self.mesh.nodes_y)), 0) v = np.r_[0, 2, 3.0] - self.assertEqual(np.linalg.norm((v - self.mesh.vectorNz)), 0) + self.assertEqual(np.linalg.norm((v - self.mesh.nodes_z)), 0) def test_edge(self): edge = np.r_[1, 2, 2.5, 1, 2, 2.5, 1, 2, 2.5] * 2 * np.pi - self.assertEqual(np.linalg.norm((edge - self.mesh.edge)), 0) + self.assertEqual(np.linalg.norm((edge - self.mesh.edge_lengths)), 0) def test_area(self): r = np.r_[0, 1, 2, 2.5] @@ -77,20 +77,20 @@ def test_area(self): a = (r[1:] ** 2 - r[:-1] ** 2) * np.pi areaZ = np.r_[a, a, a] area = np.r_[areaX, areaZ] - self.assertEqual(np.linalg.norm((area - self.mesh.area)), 0) + self.assertEqual(np.linalg.norm((area - self.mesh.face_areas)), 0) def test_vol(self): r = np.r_[0, 1, 2, 2.5] a = (r[1:] ** 2 - r[:-1] ** 2) * np.pi vol = np.r_[2 * a, a] - self.assertEqual(np.linalg.norm((vol - self.mesh.vol)), 0) + self.assertEqual(np.linalg.norm((vol - self.mesh.cell_volumes)), 0) def test_vol_simple(self): - mesh = discretize.CylMesh([1.0, 1.0, 1.0]) - self.assertEqual(mesh.vol, np.pi) + mesh = discretize.CylindricalMesh([1.0, 1.0, 1.0]) + self.assertEqual(mesh.cell_volumes, np.pi) - mesh = discretize.CylMesh([2.0, 1.0, 1.0]) - self.assertTrue(np.all(mesh.vol == np.pi * np.r_[0.5**2, 1 - 0.5**2])) + mesh = discretize.CylindricalMesh([2.0, 1.0, 1.0]) + self.assertTrue(np.all(mesh.cell_volumes == np.pi * np.r_[0.5**2, 1 - 0.5**2])) def test_gridSizes(self): self.assertEqual(self.mesh.gridCC.shape, (self.mesh.nC, 3)) @@ -140,59 +140,59 @@ def test_gridEy(self): self.assertEqual(np.linalg.norm((G - self.mesh.gridEy).ravel()), 0) def test_lightOperators(self): - self.assertTrue(self.mesh.nodalGrad is None) + self.assertTrue(self.mesh.nodal_gradient is None) def test_getInterpMatCartMesh_Cells(self): Mr = discretize.TensorMesh([100, 100, 2], x0="CC0") - Mc = discretize.CylMesh( - [np.ones(10) / 5, 1, 10], x0="0C0", cartesianOrigin=[-0.2, -0.2, 0] + Mc = discretize.CylindricalMesh( + [np.ones(10) / 5, 1, 10], x0="0C0", cartesian_origin=[-0.2, -0.2, 0] ) mc = np.arange(Mc.nC) xr = np.linspace(0, 0.4, 50) xc = np.linspace(0, 0.4, 50) + 0.2 - Pr = Mr.getInterpolationMat( + Pr = Mr.get_interpolation_matrix( np.c_[xr, np.ones(50) * -0.2, np.ones(50) * 0.5], "CC" ) - Pc = Mc.getInterpolationMat(np.c_[xc, np.zeros(50), np.ones(50) * 0.5], "CC") - Pc2r = Mc.getInterpolationMatCartMesh(Mr, "CC") + Pc = Mc.get_interpolation_matrix(np.c_[xc, np.zeros(50), np.ones(50) * 0.5], "CC") + Pc2r = Mc.get_interpolation_matrix_cartesian_mesh(Mr, "CC") assert np.abs(Pr * (Pc2r * mc) - Pc * mc).max() < 1e-3 def test_getInterpMatCartMesh_Cells2Nodes(self): Mr = discretize.TensorMesh([100, 100, 2], x0="CC0") - Mc = discretize.CylMesh( - [np.ones(10) / 5, 1, 10], x0="0C0", cartesianOrigin=[-0.2, -0.2, 0] + Mc = discretize.CylindricalMesh( + [np.ones(10) / 5, 1, 10], x0="0C0", cartesian_origin=[-0.2, -0.2, 0] ) mc = np.arange(Mc.nC) xr = np.linspace(0, 0.4, 50) xc = np.linspace(0, 0.4, 50) + 0.2 - Pr = Mr.getInterpolationMat( + Pr = Mr.get_interpolation_matrix( np.c_[xr, np.ones(50) * -0.2, np.ones(50) * 0.5], "N" ) - Pc = Mc.getInterpolationMat(np.c_[xc, np.zeros(50), np.ones(50) * 0.5], "CC") - Pc2r = Mc.getInterpolationMatCartMesh(Mr, "CC", locTypeTo="N") + Pc = Mc.get_interpolation_matrix(np.c_[xc, np.zeros(50), np.ones(50) * 0.5], "CC") + Pc2r = Mc.get_interpolation_matrix_cartesian_mesh(Mr, "CC", location_type_to="N") assert np.abs(Pr * (Pc2r * mc) - Pc * mc).max() < 1e-3 def test_getInterpMatCartMesh_Faces(self): Mr = discretize.TensorMesh([100, 100, 2], x0="CC0") - Mc = discretize.CylMesh( - [np.ones(10) / 5, 1, 10], x0="0C0", cartesianOrigin=[-0.2, -0.2, 0] + Mc = discretize.CylindricalMesh( + [np.ones(10) / 5, 1, 10], x0="0C0", cartesian_origin=[-0.2, -0.2, 0] ) - Pf = Mc.getInterpolationMatCartMesh(Mr, "F") + Pf = Mc.get_interpolation_matrix_cartesian_mesh(Mr, "F") mf = np.ones(Mc.nF) frect = Pf * mf - fxcc = Mr.aveFx2CC * Mr.r(frect, "F", "Fx") - fycc = Mr.aveFy2CC * Mr.r(frect, "F", "Fy") - fzcc = Mr.r(frect, "F", "Fz") + fxcc = Mr.aveFx2CC * Mr.reshape(frect, "F", "Fx") + fycc = Mr.aveFy2CC * Mr.reshape(frect, "F", "Fy") + fzcc = Mr.reshape(frect, "F", "Fz") - indX = utils.closestPoints(Mr, [0.45, -0.2, 0.5]) - indY = utils.closestPoints(Mr, [-0.2, 0.45, 0.5]) + indX = utils.closest_points_index(Mr, [0.45, -0.2, 0.5]) + indY = utils.closest_points_index(Mr, [-0.2, 0.45, 0.5]) TOL = 1e-2 assert np.abs(float(fxcc[indX]) - 1) < TOL @@ -209,23 +209,23 @@ def test_getInterpMatCartMesh_Faces(self): def test_getInterpMatCartMesh_Faces2Edges(self): Mr = discretize.TensorMesh([100, 100, 2], x0="CC0") - Mc = discretize.CylMesh( - [np.ones(10) / 5, 1, 10], x0="0C0", cartesianOrigin=[-0.2, -0.2, 0] + Mc = discretize.CylindricalMesh( + [np.ones(10) / 5, 1, 10], x0="0C0", cartesian_origin=[-0.2, -0.2, 0] ) - self.assertTrue((Mc.cartesianOrigin == [-0.2, -0.2, 0]).all()) + self.assertTrue((Mc.cartesian_origin == [-0.2, -0.2, 0]).all()) - Pf2e = Mc.getInterpolationMatCartMesh(Mr, "F", locTypeTo="E") + Pf2e = Mc.get_interpolation_matrix_cartesian_mesh(Mr, "F", location_type_to="E") mf = np.ones(Mc.nF) ecart = Pf2e * mf - excc = Mr.aveEx2CC * Mr.r(ecart, "E", "Ex") - eycc = Mr.aveEy2CC * Mr.r(ecart, "E", "Ey") - ezcc = Mr.r(ecart, "E", "Ez") + excc = Mr.aveEx2CC * Mr.reshape(ecart, "E", "Ex") + eycc = Mr.aveEy2CC * Mr.reshape(ecart, "E", "Ey") + ezcc = Mr.reshape(ecart, "E", "Ez") - indX = utils.closestPoints(Mr, [0.45, -0.2, 0.5]) - indY = utils.closestPoints(Mr, [-0.2, 0.45, 0.5]) + indX = utils.closest_points_index(Mr, [0.45, -0.2, 0.5]) + indY = utils.closest_points_index(Mr, [-0.2, 0.45, 0.5]) TOL = 1e-2 assert np.abs(float(excc[indX]) - 1) < TOL @@ -242,21 +242,21 @@ def test_getInterpMatCartMesh_Faces2Edges(self): def test_getInterpMatCartMesh_Edges(self): Mr = discretize.TensorMesh([100, 100, 2], x0="CC0") - Mc = discretize.CylMesh( - [np.ones(10) / 5, 1, 10], x0="0C0", cartesianOrigin=[-0.2, -0.2, 0] + Mc = discretize.CylindricalMesh( + [np.ones(10) / 5, 1, 10], x0="0C0", cartesian_origin=[-0.2, -0.2, 0] ) - Pe = Mc.getInterpolationMatCartMesh(Mr, "E") + Pe = Mc.get_interpolation_matrix_cartesian_mesh(Mr, "E") me = np.ones(Mc.nE) ecart = Pe * me - excc = Mr.aveEx2CC * Mr.r(ecart, "E", "Ex") - eycc = Mr.aveEy2CC * Mr.r(ecart, "E", "Ey") - ezcc = Mr.aveEz2CC * Mr.r(ecart, "E", "Ez") + excc = Mr.aveEx2CC * Mr.reshape(ecart, "E", "Ex") + eycc = Mr.aveEy2CC * Mr.reshape(ecart, "E", "Ey") + ezcc = Mr.aveEz2CC * Mr.reshape(ecart, "E", "Ez") - indX = utils.closestPoints(Mr, [0.45, -0.2, 0.5]) - indY = utils.closestPoints(Mr, [-0.2, 0.45, 0.5]) + indX = utils.closest_points_index(Mr, [0.45, -0.2, 0.5]) + indY = utils.closest_points_index(Mr, [-0.2, 0.45, 0.5]) TOL = 1e-2 assert np.abs(float(excc[indX]) - 0) < TOL @@ -273,21 +273,21 @@ def test_getInterpMatCartMesh_Edges(self): def test_getInterpMatCartMesh_Edges2Faces(self): Mr = discretize.TensorMesh([100, 100, 2], x0="CC0") - Mc = discretize.CylMesh( - [np.ones(10) / 5, 1, 10], x0="0C0", cartesianOrigin=[-0.2, -0.2, 0] + Mc = discretize.CylindricalMesh( + [np.ones(10) / 5, 1, 10], x0="0C0", cartesian_origin=[-0.2, -0.2, 0] ) - Pe2f = Mc.getInterpolationMatCartMesh(Mr, "E", locTypeTo="F") + Pe2f = Mc.get_interpolation_matrix_cartesian_mesh(Mr, "E", location_type_to="F") me = np.ones(Mc.nE) frect = Pe2f * me - excc = Mr.aveFx2CC * Mr.r(frect, "F", "Fx") - eycc = Mr.aveFy2CC * Mr.r(frect, "F", "Fy") - ezcc = Mr.r(frect, "F", "Fz") + excc = Mr.aveFx2CC * Mr.reshape(frect, "F", "Fx") + eycc = Mr.aveFy2CC * Mr.reshape(frect, "F", "Fy") + ezcc = Mr.reshape(frect, "F", "Fz") - indX = utils.closestPoints(Mr, [0.45, -0.2, 0.5]) - indY = utils.closestPoints(Mr, [-0.2, 0.45, 0.5]) + indX = utils.closest_points_index(Mr, [0.45, -0.2, 0.5]) + indY = utils.closest_points_index(Mr, [-0.2, 0.45, 0.5]) TOL = 1e-2 assert np.abs(float(excc[indX]) - 0) < TOL @@ -303,12 +303,12 @@ def test_getInterpMatCartMesh_Edges2Faces(self): assert np.abs(mag[dist > 0.1].min() - 1) < TOL def test_serialization(self): - mesh = discretize.CylMesh.deserialize(self.mesh.serialize()) + mesh = discretize.CylindricalMesh.deserialize(self.mesh.serialize()) self.assertTrue(np.all(self.mesh.x0 == mesh.x0)) self.assertTrue(np.all(self.mesh.shape_cells == mesh.shape_cells)) - self.assertTrue(np.all(self.mesh.hx == mesh.hx)) - self.assertTrue(np.all(self.mesh.hy == mesh.hy)) - self.assertTrue(np.all(self.mesh.hz == mesh.hz)) + self.assertTrue(np.all(self.mesh.h[0] == mesh.h[0])) + self.assertTrue(np.all(self.mesh.h[1] == mesh.h[1])) + self.assertTrue(np.all(self.mesh.h[2] == mesh.h[2])) self.assertTrue(np.all(self.mesh.gridCC == mesh.gridCC)) @@ -339,9 +339,9 @@ def getError(self): Fc = cylF2(self.M, funR, funZ) Fc = np.c_[Fc[:, 0], np.zeros(self.M.nF), Fc[:, 1]] - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) - divF = self.M.faceDiv.dot(F) + divF = self.M.face_divergence.dot(F) divF_ana = call3(sol, self.M.gridCC) err = np.linalg.norm((divF - divF_ana), np.inf) @@ -377,11 +377,11 @@ def getError(self): E = call3(funT, self.M.gridEy) - curlE = self.M.edgeCurl.dot(E) + curlE = self.M.edge_curl.dot(E) Fc = cylF2(self.M, solR, solZ) Fc = np.c_[Fc[:, 0], np.zeros(self.M.nF), Fc[:, 1]] - curlE_ana = self.M.projectFaceVector(Fc) + curlE_ana = self.M.project_face_vector(Fc) err = np.linalg.norm((curlE - curlE_ana), np.inf) return err @@ -406,9 +406,9 @@ class TestCellGrad2D_Dirichlet(unittest.TestCase): # Fc = cylF2(self.M, fx, fz) # Fc = np.c_[Fc[:, 0], np.zeros(self.M.nF), Fc[:, 1]] - # gradX_ana = self.M.projectFaceVector(Fc) + # gradX_ana = self.M.project_face_vector(Fc) - # gradX = self.M.cellGrad.dot(xc) + # gradX = self.M.cell_gradient.dot(xc) # err = np.linalg.norm((gradX-gradX_ana), np.inf) @@ -420,18 +420,18 @@ class TestCellGrad2D_Dirichlet(unittest.TestCase): def setUp(self): hx = np.random.rand(10) hz = np.random.rand(10) - self.mesh = discretize.CylMesh([hx, 1, hz]) + self.mesh = discretize.CylindricalMesh([hx, 1, hz]) def test_NotImplementedError(self): with self.assertRaises(NotImplementedError): - self.mesh.cellGrad + self.mesh.cell_gradient class TestAveragingSimple(unittest.TestCase): def setUp(self): hx = np.random.rand(10) hz = np.random.rand(10) - self.mesh = discretize.CylMesh([hx, 1, hz]) + self.mesh = discretize.CylindricalMesh([hx, 1, hz]) def test_simpleEdges(self): edge_vec = self.mesh.gridEy[:, 0] @@ -504,7 +504,7 @@ def getError(self): Fc = cylF2(self.M, funR, funZ) Fc = np.c_[Fc[:, 0], np.zeros(self.M.nF), Fc[:, 1]] - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) aveF = self.M.aveF2CCV * F @@ -530,7 +530,7 @@ def getError(self): Fc = cylF2(self.M, fun, fun) Fc = np.c_[Fc[:, 0], np.zeros(self.M.nF), Fc[:, 1]] - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) aveF = self.M.aveF2CC * F aveF_ana = fun(self.M.gridCC[:, 0], self.M.gridCC[:, 2]) @@ -577,12 +577,12 @@ def test_order(self): # if self.location == 'edges': # E = call(funT, self.M.gridEy) -# A = self.M.getEdgeInnerProduct(sigma) +# A = self.M.get_edge_inner_product(sigma) # numeric = E.T.dot(A.dot(E)) # elif self.location == 'faces': # Fr = call(funR, self.M.gridFx) # Fz = call(funZ, self.M.gridFz) -# A = self.M.getFaceInnerProduct(sigma) +# A = self.M.get_face_inner_product(sigma) # F = np.r_[Fr, Fz] # numeric = F.T.dot(A.dot(F)) @@ -602,22 +602,22 @@ def setUp(self): hx = np.r_[1, 1, 0.5] hy = np.r_[np.pi, np.pi] hz = np.r_[2, 1] - self.mesh = discretize.CylMesh([hx, hy, hz]) + self.mesh = discretize.CylindricalMesh([hx, hy, hz]) def test_dim(self): self.assertEqual(self.mesh.dim, 3) def test_nC(self): - self.assertEqual(self.mesh.nCx, 3) - self.assertEqual(self.mesh.nCy, 2) - self.assertEqual(self.mesh.nCz, 2) + self.assertEqual(self.mesh.shape_cells[0], 3) + self.assertEqual(self.mesh.shape_cells[1], 2) + self.assertEqual(self.mesh.shape_cells[2], 2) self.assertEqual(self.mesh.vnC, (3, 2, 2)) def test_nN(self): self.assertEqual(self.mesh.nN, 21) - self.assertEqual(self.mesh.nNx, 4) - self.assertEqual(self.mesh.nNy, 2) - self.assertEqual(self.mesh.nNz, 3) + self.assertEqual(self.mesh.shape_nodes[0], 4) + self.assertEqual(self.mesh.shape_nodes[1], 2) + self.assertEqual(self.mesh.shape_nodes[2], 3) self.assertEqual(self.mesh.vnN, (4, 2, 3)) def test_nF(self): @@ -642,19 +642,19 @@ def test_nE(self): def test_vectorsCC(self): v = np.r_[0.5, 1.5, 2.25] - self.assertEqual(np.linalg.norm((v - self.mesh.vectorCCx)), 0) + self.assertEqual(np.linalg.norm((v - self.mesh.cell_centers_x)), 0) v = np.r_[0, np.pi] + np.pi / 2 - self.assertEqual(np.linalg.norm((v - self.mesh.vectorCCy)), 0) + self.assertEqual(np.linalg.norm((v - self.mesh.cell_centers_y)), 0) v = np.r_[1, 2.5] - self.assertEqual(np.linalg.norm((v - self.mesh.vectorCCz)), 0) + self.assertEqual(np.linalg.norm((v - self.mesh.cell_centers_z)), 0) def test_vectorsN(self): v = np.r_[0, 1, 2, 2.5] - self.assertEqual(np.linalg.norm((v - self.mesh.vectorNx)), 0) + self.assertEqual(np.linalg.norm((v - self.mesh.nodes_x)), 0) v = np.r_[0.0, np.pi] - self.assertEqual(np.linalg.norm((v - self.mesh.vectorNy)), 0) + self.assertEqual(np.linalg.norm((v - self.mesh.nodes_y)), 0) v = np.r_[0, 2, 3] - self.assertEqual(np.linalg.norm((v - self.mesh.vectorNz)), 0) + self.assertEqual(np.linalg.norm((v - self.mesh.nodes_z)), 0) if __name__ == "__main__": diff --git a/tests/cyl/test_cyl3D.py b/tests/cyl/test_cyl3D.py index b2d96b682..47c133eaf 100644 --- a/tests/cyl/test_cyl3D.py +++ b/tests/cyl/test_cyl3D.py @@ -11,60 +11,60 @@ class TestCyl3DGeometries(unittest.TestCase): def setUp(self): - hx = utils.meshTensor([(1, 1)]) - htheta = utils.meshTensor([(1.0, 4)]) + hx = utils.unpack_widths([(1, 1)]) + htheta = utils.unpack_widths([(1.0, 4)]) htheta = htheta * 2 * np.pi / htheta.sum() hz = hx - self.mesh = discretize.CylMesh([hx, htheta, hz]) + self.mesh = discretize.CylindricalMesh([hx, htheta, hz]) def test_areas(self): - area = self.mesh.area + area = self.mesh.face_areas self.assertTrue(self.mesh.nF == len(area)) self.assertTrue( - area[: self.mesh.vnF[0]].sum() == 2 * np.pi * self.mesh.hx * self.mesh.hz + area[: self.mesh.vnF[0]].sum() == 2 * np.pi * self.mesh.h[0] * self.mesh.h[2] ) self.assertTrue( np.all( - area[self.mesh.vnF[0] : self.mesh.vnF[1]] == self.mesh.hx * self.mesh.hz + area[self.mesh.vnF[0] : self.mesh.vnF[1]] == self.mesh.h[0] * self.mesh.h[2] ) ) self.assertTrue( np.all( area[sum(self.mesh.vnF[:2]) :] - == np.pi * self.mesh.hx**2 / self.mesh.nCy + == np.pi * self.mesh.h[0]**2 / self.mesh.shape_cells[1] ) ) def test_edges(self): - edge = self.mesh.edge + edge = self.mesh.edge_lengths self.assertTrue(self.mesh.nE == len(edge)) - self.assertTrue(np.all(edge[: self.mesh.vnF[0]] == self.mesh.hx)) + self.assertTrue(np.all(edge[: self.mesh.vnF[0]] == self.mesh.h[0])) self.assertTrue( np.all( - self.mesh.edge[self.mesh.vnE[0] : sum(self.mesh.vnE[:2])] - == np.kron(np.ones(self.mesh.nCz + 1), self.mesh.hx * self.mesh.hy) + self.mesh.edge_lengths[self.mesh.vnE[0] : sum(self.mesh.vnE[:2])] + == np.kron(np.ones(self.mesh.shape_cells[2] + 1), self.mesh.h[0] * self.mesh.h[1]) ) ) self.assertTrue( np.all( - self.mesh.edge[self.mesh.vnE[0] : sum(self.mesh.vnE[:2])] - == np.kron(np.ones(self.mesh.nCz + 1), self.mesh.hx * self.mesh.hy) + self.mesh.edge_lengths[self.mesh.vnE[0] : sum(self.mesh.vnE[:2])] + == np.kron(np.ones(self.mesh.shape_cells[2] + 1), self.mesh.h[0] * self.mesh.h[1]) ) ) self.assertTrue( np.all( - self.mesh.edge[sum(self.mesh.vnE[:2]) :] - == np.kron(self.mesh.hz, np.ones(self.mesh.nCy + 1)) + self.mesh.edge_lengths[sum(self.mesh.vnE[:2]) :] + == np.kron(self.mesh.h[2], np.ones(self.mesh.shape_cells[1] + 1)) ) ) def test_vol(self): - self.assertTrue(self.mesh.vol.sum() == np.pi * self.mesh.hx**2 * self.mesh.hz) + self.assertTrue(self.mesh.cell_volumes.sum() == np.pi * self.mesh.h[0]**2 * self.mesh.h[2]) self.assertTrue( np.all( - self.mesh.vol - == np.pi * self.mesh.hx**2 * self.mesh.hz / self.mesh.nCy + self.mesh.cell_volumes + == np.pi * self.mesh.h[0]**2 * self.mesh.h[2] / self.mesh.shape_cells[1] ) ) @@ -96,16 +96,16 @@ def test_boundary_items(): class Cyl3DGrid(unittest.TestCase): def setUp(self): - self.mesh = discretize.CylMesh([2, 4, 1]) + self.mesh = discretize.CylindricalMesh([2, 4, 1]) def test_counting(self): mesh = self.mesh # cell centers self.assertEqual(mesh.nC, 8) - self.assertEqual(mesh.nCx, 2) - self.assertEqual(mesh.nCy, 4) - self.assertEqual(mesh.nCz, 1) + self.assertEqual(mesh.shape_cells[0], 2) + self.assertEqual(mesh.shape_cells[1], 4) + self.assertEqual(mesh.shape_cells[2], 1) self.assertEqual(mesh.vnC, (2, 4, 1)) # faces @@ -130,9 +130,9 @@ def test_counting(self): self.assertNotEqual(np.prod(mesh.vnEz), mesh.nEz) # periodic boundary condition # nodes - self.assertEqual(mesh.nNx, 3) - self.assertEqual(mesh.nNy, 4) - self.assertEqual(mesh.nNz, 2) + self.assertEqual(mesh.shape_nodes[0], 3) + self.assertEqual(mesh.shape_nodes[1], 4) + self.assertEqual(mesh.shape_nodes[2], 2) self.assertEqual(mesh.vnN, (3, 4, 2)) self.assertEqual(mesh.nN, 18) self.assertNotEqual(mesh.nN, np.prod(mesh.vnN)) # periodic boundary condition @@ -141,14 +141,14 @@ def test_gridCC(self): mesh = self.mesh # Cell centers - self.assertTrue((mesh.vectorCCx == [0.25, 0.75]).all()) + self.assertTrue((mesh.cell_centers_x == [0.25, 0.75]).all()) self.assertTrue( ( - mesh.vectorCCy + mesh.cell_centers_y == 2.0 * np.pi * np.r_[1.0 / 8.0, 3.0 / 8.0, 5.0 / 8.0, 7.0 / 8.0] ).all() ) - self.assertTrue(mesh.vectorCCz == 0.5) + self.assertTrue(mesh.cell_centers_z == 0.5) self.assertTrue((mesh.gridCC[:, 0] == 4 * [0.25, 0.75]).all()) self.assertTrue( @@ -174,11 +174,11 @@ def test_gridN(self): mesh = self.mesh # Nodes - self.assertTrue((mesh.vectorNx == [0.0, 0.5, 1.0]).all()) + self.assertTrue((mesh.nodes_x == [0.0, 0.5, 1.0]).all()) self.assertTrue( - (mesh.vectorNy == 2 * np.pi * np.r_[0.0, 0.25, 0.5, 0.75]).all() + (mesh.nodes_y == 2 * np.pi * np.r_[0.0, 0.25, 0.5, 0.75]).all() ) - self.assertTrue((mesh.vectorNz == np.r_[0.0, 1.0]).all()) + self.assertTrue((mesh.nodes_z == np.r_[0.0, 1.0]).all()) self.assertTrue( ( @@ -319,12 +319,12 @@ def test_gridEz(self): class TestCartesianGrid(unittest.TestCase): def test_cartesianGrid(self): - mesh = discretize.CylMesh([1, 4, 1]) + mesh = discretize.CylindricalMesh([1, 4, 1]) root2over2 = np.sqrt(2.0) / 2.0 # cell centers - cartCC = mesh.cartesianGrid("CC") + cartCC = mesh.cartesian_grid("CC") self.assertTrue( np.allclose(cartCC[:, 0], 0.5 * root2over2 * np.r_[1.0, -1.0, -1.0, 1.0]) ) @@ -334,7 +334,7 @@ def test_cartesianGrid(self): self.assertTrue(np.allclose(cartCC[:, 2], 0.5 * np.ones(4))) # nodes - cartN = mesh.cartesianGrid("N") + cartN = mesh.cartesian_grid("N") self.assertTrue( np.allclose(cartN[:, 0], np.hstack(2 * [0.0, 1.0, 0.0, -1.0, 0.0])) ) @@ -346,15 +346,15 @@ def test_cartesianGrid(self): class Deflation(unittest.TestCase): def test_areas(self): - mesh = discretize.CylMesh([1, 2, 1]) + mesh = discretize.CylindricalMesh([1, 2, 1]) areas = np.hstack([[np.pi] * 2, [1] * 2, [np.pi / 2] * 4]) - self.assertTrue(np.all(mesh.area == areas)) + self.assertTrue(np.all(mesh.face_areas == areas)) edges = np.hstack([[1] * 4, [np.pi] * 4, [1] * 3]) - self.assertTrue(np.all(mesh.edge == edges)) + self.assertTrue(np.all(mesh.edge_lengths == edges)) - mesh = discretize.CylMesh([2, 5, 3]) + mesh = discretize.CylindricalMesh([2, 5, 3]) hangingF = np.hstack( [ @@ -362,14 +362,14 @@ def test_areas(self): for dim in ["x", "y", "z"] ] ) - self.assertTrue(np.all(mesh._face_areas_full[~hangingF] == mesh.area)) + self.assertTrue(np.all(mesh._face_areas_full[~hangingF] == mesh.face_areas)) hangingE = np.hstack( [ getattr(mesh, "_ishanging_edges_{}".format(dim)) for dim in ["x", "y", "z"] ] ) - self.assertTrue(np.all(mesh._edge_lengths_full[~hangingE] == mesh.edge)) + self.assertTrue(np.all(mesh._edge_lengths_full[~hangingE] == mesh.edge_lengths)) if __name__ == "__main__": diff --git a/tests/cyl/test_cylOperators.py b/tests/cyl/test_cylOperators.py index a8153cf63..52a7f4c81 100644 --- a/tests/cyl/test_cylOperators.py +++ b/tests/cyl/test_cylOperators.py @@ -56,7 +56,7 @@ # phi = call3(fun, self.M.gridCC) -# phix_num = self.M.cellGradx * phi +# phix_num = self.M.cell_gradient_x * phi # phix_ana = call3(solR, self.M.gridFx) # err = np.linalg.norm(phix_num - phix_ana, np.inf) @@ -85,9 +85,9 @@ def getError(self): Fc = cylF3(self.M, funR, funT, funZ) # Fc = np.c_[Fc[:, 0], np.zeros(self.M.nF), Fc[:, 1]] - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) - divF = self.M.faceDiv.dot(F) + divF = self.M.face_divergence.dot(F) divF_ana = call3(sol, self.M.gridCC) err = np.linalg.norm((divF - divF_ana), np.inf) @@ -98,7 +98,7 @@ def test_order(self): class TestEdgeCurl3D(tests.OrderTest): - name = "edgeCurl" + name = "edge_curl" meshTypes = MESHTYPES meshDimension = 3 meshSizes = [8, 16, 32, 64] @@ -140,11 +140,11 @@ def getError(self): ) Ec = cylE3(self.M, funR, funT, funZ) - E = self.M.projectEdgeVector(Ec) - curlE_num = self.M.edgeCurl * E + E = self.M.project_edge_vector(Ec) + curlE_num = self.M.edge_curl * E Fc = cylF3(self.M, sol_r, sol_t, sol_z) - curlE_ana = self.M.projectFaceVector(Fc) + curlE_ana = self.M.project_face_vector(Fc) err = np.linalg.norm((curlE_num - curlE_ana), np.inf) return err @@ -160,7 +160,7 @@ def setUp(self): hy = np.random.rand(n) hy = hy * 2 * np.pi / hy.sum() hz = np.random.rand(n) - self.mesh = discretize.CylMesh([hx, hy, hz]) + self.mesh = discretize.CylindricalMesh([hx, hy, hz]) def test_constantEdges(self): funR = lambda r, t, z: r @@ -168,7 +168,7 @@ def test_constantEdges(self): funZ = lambda r, t, z: z Ec = cylE3(self.mesh, funR, funT, funZ) - E = self.mesh.projectEdgeVector(Ec) + E = self.mesh.project_edge_vector(Ec) aveE = self.mesh.aveE2CCV * E @@ -192,7 +192,7 @@ def test_simplefct(self): funZ = lambda r, t, z: z Fc = cylF3(self.mesh, funR, funT, funZ) - F = self.mesh.projectFaceVector(Fc) + F = self.mesh.project_face_vector(Fc) aveF = self.mesh.aveF2CCV * F @@ -224,7 +224,7 @@ def getError(self): funZ = lambda r, t, z: np.sin(np.pi * z) * np.sin(2 * np.pi * r) * np.sin(t) Fc = cylF3(self.M, funR, funT, funZ) - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) aveF = self.M.aveF2CCV * F @@ -248,7 +248,7 @@ def getError(self): fun = lambda r, t, z: np.sin(np.pi * z) * np.sin(np.pi * r) * np.sin(t) Fc = cylF3(self.M, fun, fun, fun) - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) aveF = self.M.aveF2CC * F aveF_ana = fun(self.M.gridCC[:, 0], self.M.gridCC[:, 1], self.M.gridCC[:, 2]) @@ -384,7 +384,7 @@ def getError(self): funZ = lambda r, t, z: np.sin(np.pi * z) * np.sin(np.pi * r) * np.sin(t) Ec = cylE3(self.M, funR, funT, funZ) - E = self.M.projectEdgeVector(Ec) + E = self.M.project_edge_vector(Ec) aveE = self.M.aveE2CCV * E @@ -411,7 +411,7 @@ def getError(self): fun = lambda r, t, z: np.sin(np.pi * z) * np.sin(np.pi * r) * np.sin(t) Ec = cylE3(self.M, fun, fun, fun) - E = self.M.projectEdgeVector(Ec) + E = self.M.project_edge_vector(Ec) aveE = self.M.aveE2CC * E aveE_ana = fun(self.M.gridCC[:, 0], self.M.gridCC[:, 1], self.M.gridCC[:, 2]) @@ -478,7 +478,7 @@ def vectors(self, mesh): class TestCylInnerProducts_simple(unittest.TestCase): def setUp(self): n = 100.0 - self.mesh = discretize.CylMesh([n, n, n]) + self.mesh = discretize.CylindricalMesh([n, n, n]) def test_FaceInnerProductIsotropic(self): # Here we will make up some j vectors that vary in space @@ -486,7 +486,7 @@ def test_FaceInnerProductIsotropic(self): fcts = FaceInnerProductFctsIsotropic() sig, jv = fcts.vectors(self.mesh) - MfSig = self.mesh.getFaceInnerProduct(sig) + MfSig = self.mesh.get_face_inner_product(sig) numeric_ans = jv.T.dot(MfSig.dot(jv)) ans = fcts.sol() @@ -506,7 +506,7 @@ def test_EdgeInnerProduct(self): fcts = EdgeInnerProductFctsIsotropic() sig, hv = fcts.vectors(self.mesh) - MeSig = self.mesh.getEdgeInnerProduct(sig) + MeSig = self.mesh.get_edge_inner_product(sig) numeric_ans = hv.T.dot(MeSig.dot(hv)) ans = fcts.sol() @@ -528,7 +528,7 @@ class TestCylFaceInnerProducts_Order(tests.OrderTest): def getError(self): fct = FaceInnerProductFctsIsotropic() sig, jv = fct.vectors(self.M) - Msig = self.M.getFaceInnerProduct(sig) + Msig = self.M.get_face_inner_product(sig) return float(fct.sol()) - jv.T.dot(Msig.dot(jv)) def test_order(self): @@ -542,7 +542,7 @@ class TestCylEdgeInnerProducts_Order(tests.OrderTest): def getError(self): fct = EdgeInnerProductFctsIsotropic() sig, hv = fct.vectors(self.M) - Msig = self.M.getEdgeInnerProduct(sig) + Msig = self.M.get_edge_inner_product(sig) return float(fct.sol()) - hv.T.dot(Msig.dot(hv)) def test_order(self): @@ -601,7 +601,7 @@ class MimeticProperties(unittest.TestCase): def test_DivCurl(self): for meshType in self.meshTypes: - mesh, _ = discretize.tests.setupMesh( + mesh, _ = discretize.tests.setup_mesh( meshType, self.meshSize, self.meshDimension ) v = np.random.rand(mesh.nE) @@ -615,7 +615,7 @@ def test_DivCurl(self): def test_CurlGrad(self): for meshType in self.meshTypes: - mesh, _ = discretize.tests.setupMesh( + mesh, _ = discretize.tests.setup_mesh( meshType, self.meshSize, self.meshDimension ) v = np.random.rand(mesh.nN) diff --git a/tests/cyl/test_cyl_innerproducts.py b/tests/cyl/test_cyl_innerproducts.py index afa0f7e62..ea6bad216 100644 --- a/tests/cyl/test_cyl_innerproducts.py +++ b/tests/cyl/test_cyl_innerproducts.py @@ -151,7 +151,7 @@ def vectors(self, mesh): class TestCylInnerProducts_simple(unittest.TestCase): def setUp(self): n = 100.0 - self.mesh = discretize.CylMesh([n, 1, n]) + self.mesh = discretize.CylindricalMesh([n, 1, n]) def test_FaceInnerProductIsotropic(self): # Here we will make up some j vectors that vary in space @@ -159,7 +159,7 @@ def test_FaceInnerProductIsotropic(self): fcts = FaceInnerProductFctsIsotropic() sig, jv = fcts.vectors(self.mesh) - MfSig = self.mesh.getFaceInnerProduct(sig) + MfSig = self.mesh.get_face_inner_product(sig) numeric_ans = jv.T.dot(MfSig.dot(jv)) ans = fcts.sol() @@ -179,7 +179,7 @@ def test_FaceInnerProductDiagAnisotropic(self): fcts = FaceInnerProductFunctionsDiagAnisotropic() sig, jv = fcts.vectors(self.mesh) - MfSig = self.mesh.getFaceInnerProduct(sig) + MfSig = self.mesh.get_face_inner_product(sig) numeric_ans = jv.T.dot(MfSig.dot(jv)) ans = fcts.sol() @@ -199,7 +199,7 @@ def test_EdgeInnerProduct(self): fcts = EdgeInnerProductFctsIsotropic() sig, hv = fcts.vectors(self.mesh) - MeSig = self.mesh.getEdgeInnerProduct(sig) + MeSig = self.mesh.get_edge_inner_product(sig) numeric_ans = hv.T.dot(MeSig.dot(hv)) ans = fcts.sol() @@ -220,7 +220,7 @@ def test_EdgeInnerProductDiagAnisotropic(self): fcts = EdgeInnerProductFunctionsDiagAnisotropic() sig, hv = fcts.vectors(self.mesh) - MeSig = self.mesh.getEdgeInnerProduct(sig) + MeSig = self.mesh.get_edge_inner_product(sig) numeric_ans = hv.T.dot(MeSig.dot(hv)) ans = fcts.sol() @@ -242,7 +242,7 @@ class TestCylFaceInnerProducts_Order(tests.OrderTest): def getError(self): fct = FaceInnerProductFctsIsotropic() sig, jv = fct.vectors(self.M) - Msig = self.M.getFaceInnerProduct(sig) + Msig = self.M.get_face_inner_product(sig) return float(fct.sol()) - jv.T.dot(Msig.dot(jv)) def test_order(self): @@ -256,7 +256,7 @@ class TestCylEdgeInnerProducts_Order(tests.OrderTest): def getError(self): fct = EdgeInnerProductFctsIsotropic() sig, ht = fct.vectors(self.M) - Msig = self.M.getEdgeInnerProduct(sig) + Msig = self.M.get_edge_inner_product(sig) return float(fct.sol()) - ht.T.dot(Msig.dot(ht)) def test_order(self): @@ -270,7 +270,7 @@ class TestCylFaceInnerProductsDiagAnisotropic_Order(tests.OrderTest): def getError(self): fct = FaceInnerProductFunctionsDiagAnisotropic() sig, jv = fct.vectors(self.M) - Msig = self.M.getFaceInnerProduct(sig) + Msig = self.M.get_face_inner_product(sig) return float(fct.sol()) - jv.T.dot(Msig.dot(jv)) def test_order(self): @@ -280,7 +280,7 @@ def test_order(self): class TestCylInnerProducts_Deriv(unittest.TestCase): def setUp(self): n = 2 - self.mesh = discretize.CylMesh([n, 1, n]) + self.mesh = discretize.CylindricalMesh([n, 1, n]) self.face_vec = np.random.rand(self.mesh.nF) self.edge_vec = np.random.rand(self.mesh.nE) # make up a smooth function @@ -288,101 +288,101 @@ def setUp(self): def test_FaceInnerProductIsotropicDeriv(self): def fun(x): - MfSig = self.mesh.getFaceInnerProduct(x) - MfSigDeriv = self.mesh.getFaceInnerProductDeriv(self.x0) + MfSig = self.mesh.get_face_inner_product(x) + MfSigDeriv = self.mesh.get_face_inner_product_deriv(self.x0) return MfSig * self.face_vec, MfSigDeriv(self.face_vec) print("Testing FaceInnerProduct Isotropic") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_FaceInnerProductIsotropicDerivInvProp(self): def fun(x): - MfSig = self.mesh.getFaceInnerProduct(x, invProp=True) - MfSigDeriv = self.mesh.getFaceInnerProductDeriv(self.x0, invProp=True) + MfSig = self.mesh.get_face_inner_product(x, invert_model=True) + MfSigDeriv = self.mesh.get_face_inner_product_deriv(self.x0, invert_model=True) return MfSig * self.face_vec, MfSigDeriv(self.face_vec) print("Testing FaceInnerProduct Isotropic InvProp") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_FaceInnerProductIsotropicDerivInvMat(self): def fun(x): - MfSig = self.mesh.getFaceInnerProduct(x, invMat=True) - MfSigDeriv = self.mesh.getFaceInnerProductDeriv(self.x0, invMat=True) + MfSig = self.mesh.get_face_inner_product(x, invert_matrix=True) + MfSigDeriv = self.mesh.get_face_inner_product_deriv(self.x0, invert_matrix=True) return MfSig * self.face_vec, MfSigDeriv(self.face_vec) print("Testing FaceInnerProduct Isotropic InvMat") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_FaceInnerProductIsotropicDerivInvPropInvMat(self): def fun(x): - MfSig = self.mesh.getFaceInnerProduct(x, invProp=True, invMat=True) - MfSigDeriv = self.mesh.getFaceInnerProductDeriv( - self.x0, invProp=True, invMat=True + MfSig = self.mesh.get_face_inner_product(x, invert_model=True, invert_matrix=True) + MfSigDeriv = self.mesh.get_face_inner_product_deriv( + self.x0, invert_model=True, invert_matrix=True ) return MfSig * self.face_vec, MfSigDeriv(self.face_vec) print("Testing FaceInnerProduct Isotropic InvProp InvMat") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_EdgeInnerProductIsotropicDeriv(self): def fun(x): - MeSig = self.mesh.getEdgeInnerProduct(x) - MeSigDeriv = self.mesh.getEdgeInnerProductDeriv(self.x0) + MeSig = self.mesh.get_edge_inner_product(x) + MeSigDeriv = self.mesh.get_edge_inner_product_deriv(self.x0) return MeSig * self.edge_vec, MeSigDeriv(self.edge_vec) print("Testing EdgeInnerProduct Isotropic") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_EdgeInnerProductIsotropicDerivInvProp(self): def fun(x): - MeSig = self.mesh.getEdgeInnerProduct(x, invProp=True) - MeSigDeriv = self.mesh.getEdgeInnerProductDeriv(self.x0, invProp=True) + MeSig = self.mesh.get_edge_inner_product(x, invert_model=True) + MeSigDeriv = self.mesh.get_edge_inner_product_deriv(self.x0, invert_model=True) return MeSig * self.edge_vec, MeSigDeriv(self.edge_vec) print("Testing EdgeInnerProduct Isotropic InvProp") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_EdgeInnerProductIsotropicDerivInvMat(self): def fun(x): - MeSig = self.mesh.getEdgeInnerProduct(x, invMat=True) - MeSigDeriv = self.mesh.getEdgeInnerProductDeriv(self.x0, invMat=True) + MeSig = self.mesh.get_edge_inner_product(x, invert_matrix=True) + MeSigDeriv = self.mesh.get_edge_inner_product_deriv(self.x0, invert_matrix=True) return MeSig * self.edge_vec, MeSigDeriv(self.edge_vec) print("Testing EdgeInnerProduct Isotropic InvMat") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_EdgeInnerProductIsotropicDerivInvPropInvMat(self): def fun(x): - MeSig = self.mesh.getEdgeInnerProduct(x, invProp=True, invMat=True) - MeSigDeriv = self.mesh.getEdgeInnerProductDeriv( - self.x0, invProp=True, invMat=True + MeSig = self.mesh.get_edge_inner_product(x, invert_model=True, invert_matrix=True) + MeSigDeriv = self.mesh.get_edge_inner_product_deriv( + self.x0, invert_model=True, invert_matrix=True ) return MeSig * self.edge_vec, MeSigDeriv(self.edge_vec) print("Testing EdgeInnerProduct Isotropic InvProp InvMat") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) class TestCylInnerProductsAnisotropic_Deriv(unittest.TestCase): def setUp(self): n = 60 - self.mesh = discretize.CylMesh([n, 1, n]) + self.mesh = discretize.CylindricalMesh([n, 1, n]) self.face_vec = np.random.rand(self.mesh.nF) self.edge_vec = np.random.rand(self.mesh.nE) # make up a smooth function @@ -401,13 +401,13 @@ def fun(x): eye = sp.eye(self.mesh.nC) P = sp.vstack([sp.hstack([eye, zero, eye])]) - MfSig = self.mesh.getFaceInnerProduct(x) - MfSigDeriv = self.mesh.getFaceInnerProductDeriv(x0) + MfSig = self.mesh.get_face_inner_product(x) + MfSigDeriv = self.mesh.get_face_inner_product_deriv(x0) return MfSig * self.face_vec, MfSigDeriv(self.face_vec) * P.T print("Testing FaceInnerProduct Anisotropic") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_FaceInnerProductAnisotropicDerivInvProp(self): @@ -419,13 +419,13 @@ def fun(x): eye = sp.eye(self.mesh.nC) P = sp.vstack([sp.hstack([eye, zero, eye])]) - MfSig = self.mesh.getFaceInnerProduct(x, invProp=True) - MfSigDeriv = self.mesh.getFaceInnerProductDeriv(x0, invProp=True) + MfSig = self.mesh.get_face_inner_product(x, invert_model=True) + MfSigDeriv = self.mesh.get_face_inner_product_deriv(x0, invert_model=True) return MfSig * self.face_vec, MfSigDeriv(self.face_vec) * P.T print("Testing FaceInnerProduct Anisotropic InvProp") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_FaceInnerProductAnisotropicDerivInvMat(self): @@ -437,13 +437,13 @@ def fun(x): eye = sp.eye(self.mesh.nC) P = sp.vstack([sp.hstack([eye, zero, eye])]) - MfSig = self.mesh.getFaceInnerProduct(x, invMat=True) - MfSigDeriv = self.mesh.getFaceInnerProductDeriv(x0, invMat=True) + MfSig = self.mesh.get_face_inner_product(x, invert_matrix=True) + MfSigDeriv = self.mesh.get_face_inner_product_deriv(x0, invert_matrix=True) return MfSig * self.face_vec, MfSigDeriv(self.face_vec) * P.T print("Testing FaceInnerProduct Anisotropic InvMat") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_FaceInnerProductAnisotropicDerivInvPropInvMat(self): @@ -455,15 +455,15 @@ def fun(x): eye = sp.eye(self.mesh.nC) P = sp.vstack([sp.hstack([eye, zero, eye])]) - MfSig = self.mesh.getFaceInnerProduct(x, invProp=True, invMat=True) - MfSigDeriv = self.mesh.getFaceInnerProductDeriv( - x0, invProp=True, invMat=True + MfSig = self.mesh.get_face_inner_product(x, invert_model=True, invert_matrix=True) + MfSigDeriv = self.mesh.get_face_inner_product_deriv( + x0, invert_model=True, invert_matrix=True ) return MfSig * self.face_vec, MfSigDeriv(self.face_vec) * P.T print("Testing FaceInnerProduct Anisotropic InvProp InvMat") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_EdgeInnerProductAnisotropicDeriv(self): @@ -475,13 +475,13 @@ def fun(x): eye = sp.eye(self.mesh.nC) P = sp.vstack([sp.hstack([zero, eye, zero])]) - MeSig = self.mesh.getEdgeInnerProduct(x.reshape(self.mesh.nC, 3)) - MeSigDeriv = self.mesh.getEdgeInnerProductDeriv(x0) + MeSig = self.mesh.get_edge_inner_product(x.reshape(self.mesh.nC, 3)) + MeSigDeriv = self.mesh.get_edge_inner_product_deriv(x0) return MeSig * self.edge_vec, MeSigDeriv(self.edge_vec) * P.T print("Testing EdgeInnerProduct Anisotropic") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_EdgeInnerProductAnisotropicDerivInvProp(self): @@ -493,13 +493,13 @@ def fun(x): eye = sp.eye(self.mesh.nC) P = sp.vstack([sp.hstack([zero, eye, zero])]) - MeSig = self.mesh.getEdgeInnerProduct(x, invProp=True) - MeSigDeriv = self.mesh.getEdgeInnerProductDeriv(x0, invProp=True) + MeSig = self.mesh.get_edge_inner_product(x, invert_model=True) + MeSigDeriv = self.mesh.get_edge_inner_product_deriv(x0, invert_model=True) return MeSig * self.edge_vec, MeSigDeriv(self.edge_vec) * P.T print("Testing EdgeInnerProduct Anisotropic InvProp") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_EdgeInnerProductAnisotropicDerivInvMat(self): @@ -511,13 +511,13 @@ def fun(x): eye = sp.eye(self.mesh.nC) P = sp.vstack([sp.hstack([zero, eye, zero])]) - MeSig = self.mesh.getEdgeInnerProduct(x, invMat=True) - MeSigDeriv = self.mesh.getEdgeInnerProductDeriv(x0, invMat=True) + MeSig = self.mesh.get_edge_inner_product(x, invert_matrix=True) + MeSigDeriv = self.mesh.get_edge_inner_product_deriv(x0, invert_matrix=True) return MeSig * self.edge_vec, MeSigDeriv(self.edge_vec) * P.T print("Testing EdgeInnerProduct Anisotropic InvMat") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) def test_EdgeInnerProductAnisotropicDerivInvPropInvMat(self): @@ -529,15 +529,15 @@ def fun(x): eye = sp.eye(self.mesh.nC) P = sp.vstack([sp.hstack([zero, eye, zero])]) - MeSig = self.mesh.getEdgeInnerProduct(x, invProp=True, invMat=True) - MeSigDeriv = self.mesh.getEdgeInnerProductDeriv( - x0, invProp=True, invMat=True + MeSig = self.mesh.get_edge_inner_product(x, invert_model=True, invert_matrix=True) + MeSigDeriv = self.mesh.get_edge_inner_product_deriv( + x0, invert_model=True, invert_matrix=True ) return MeSig * self.edge_vec, MeSigDeriv(self.edge_vec) * P.T print("Testing EdgeInnerProduct Anisotropic InvProp InvMat") return self.assertTrue( - tests.checkDerivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) + tests.check_derivative(fun, self.x0, num=7, tolerance=TOLD, plotIt=False) ) diff --git a/tests/simplex/test_inner_products.py b/tests/simplex/test_inner_products.py index 41f32b79b..6e5f64a07 100644 --- a/tests/simplex/test_inner_products.py +++ b/tests/simplex/test_inner_products.py @@ -75,9 +75,9 @@ def getError(self): p = mesh.edges Ec = np.c_[ex(*p.T), ey(*p.T)] E = mesh.project_edge_vector(Ec) - if self.invProp: + if self.invert_model: sigma = discretize.utils.inverse_property_tensor(mesh, sigma) - A = mesh.get_edge_inner_product(sigma, invert_model=self.invProp) + A = mesh.get_edge_inner_product(sigma, invert_model=self.invert_model) numeric = E.T.dot(A.dot(E)) elif self.location == "faces": @@ -85,10 +85,10 @@ def getError(self): Fc = np.c_[ex(*p.T), ey(*p.T)] F = mesh.project_face_vector(Fc) - if self.invProp: + if self.invert_model: sigma = discretize.utils.inverse_property_tensor(mesh, sigma) - A = self.M.get_face_inner_product(sigma, invert_model=self.invProp) + A = self.M.get_face_inner_product(sigma, invert_model=self.invert_model) numeric = F.T.dot(A.dot(F)) err = np.abs(numeric - analytic) @@ -98,84 +98,84 @@ def test_order1_edges(self): self.name = "Edge Inner Product - Isotropic" self.location = "edges" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_edges_invProp(self): - self.name = "Edge Inner Product - Isotropic - invProp" + def test_order1_edges_invert_model(self): + self.name = "Edge Inner Product - Isotropic - invert_model" self.location = "edges" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() def test_order2_edges(self): self.name = "Edge Inner Product - Anisotropic" self.location = "edges" self.sigmaTest = 2 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order2_edges_invProp(self): - self.name = "Edge Inner Product - Anisotropic - invProp" + def test_order2_edges_invert_model(self): + self.name = "Edge Inner Product - Anisotropic - invert_model" self.location = "edges" self.sigmaTest = 2 - self.invProp = True + self.invert_model = True self.orderTest() def test_order3_edges(self): self.name = "Edge Inner Product - Full Tensor" self.location = "edges" self.sigmaTest = 3 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order3_edges_invProp(self): - self.name = "Edge Inner Product - Full Tensor - invProp" + def test_order3_edges_invert_model(self): + self.name = "Edge Inner Product - Full Tensor - invert_model" self.location = "edges" self.sigmaTest = 3 - self.invProp = True + self.invert_model = True self.orderTest() def test_order1_faces(self): self.name = "Face Inner Product - Isotropic" self.location = "faces" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_faces_invProp(self): - self.name = "Face Inner Product - Isotropic - invProp" + def test_order1_faces_invert_model(self): + self.name = "Face Inner Product - Isotropic - invert_model" self.location = "faces" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() def test_order2_faces(self): self.name = "Face Inner Product - Anisotropic" self.location = "faces" self.sigmaTest = 2 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order2_faces_invProp(self): - self.name = "Face Inner Product - Anisotropic - invProp" + def test_order2_faces_invert_model(self): + self.name = "Face Inner Product - Anisotropic - invert_model" self.location = "faces" self.sigmaTest = 2 - self.invProp = True + self.invert_model = True self.orderTest() def test_order3_faces(self): self.name = "Face Inner Product - Full Tensor" self.location = "faces" self.sigmaTest = 3 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order3_faces_invProp(self): - self.name = "Face Inner Product - Full Tensor - invProp" + def test_order3_faces_invert_model(self): + self.name = "Face Inner Product - Full Tensor - invert_model" self.location = "faces" self.sigmaTest = 3 - self.invProp = True + self.invert_model = True self.orderTest() @@ -224,9 +224,9 @@ def getError(self): cart = lambda g: np.c_[ex(*g.T), ey(*g.T), ez(*g.T)] Ec = cart(mesh.edges) E = mesh.project_edge_vector(Ec) - if self.invProp: + if self.invert_model: sigma = discretize.utils.inverse_property_tensor(mesh, sigma) - A = mesh.get_edge_inner_product(sigma, invert_model=self.invProp) + A = mesh.get_edge_inner_product(sigma, invert_model=self.invert_model) numeric = E.T.dot(A.dot(E)) elif self.location == "faces": @@ -234,10 +234,10 @@ def getError(self): Fc = cart(mesh.faces) F = mesh.project_face_vector(Fc) - if self.invProp: + if self.invert_model: sigma = discretize.utils.inverse_property_tensor(mesh, sigma) - A = self.M.get_face_inner_product(sigma, invert_model=self.invProp) + A = self.M.get_face_inner_product(sigma, invert_model=self.invert_model) numeric = F.T.dot(A.dot(F)) err = np.abs(numeric - analytic) @@ -247,84 +247,84 @@ def test_order1_edges(self): self.name = "Edge Inner Product - Isotropic" self.location = "edges" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_edges_invProp(self): - self.name = "Edge Inner Product - Isotropic - invProp" + def test_order1_edges_invert_model(self): + self.name = "Edge Inner Product - Isotropic - invert_model" self.location = "edges" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() def test_order3_edges(self): self.name = "Edge Inner Product - Anisotropic" self.location = "edges" self.sigmaTest = 3 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order3_edges_invProp(self): - self.name = "Edge Inner Product - Anisotropic - invProp" + def test_order3_edges_invert_model(self): + self.name = "Edge Inner Product - Anisotropic - invert_model" self.location = "edges" self.sigmaTest = 3 - self.invProp = True + self.invert_model = True self.orderTest() def test_order6_edges(self): self.name = "Edge Inner Product - Full Tensor" self.location = "edges" self.sigmaTest = 6 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order6_edges_invProp(self): - self.name = "Edge Inner Product - Full Tensor - invProp" + def test_order6_edges_invert_model(self): + self.name = "Edge Inner Product - Full Tensor - invert_model" self.location = "edges" self.sigmaTest = 6 - self.invProp = True + self.invert_model = True self.orderTest() def test_order1_faces(self): self.name = "Face Inner Product - Isotropic" self.location = "faces" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_faces_invProp(self): - self.name = "Face Inner Product - Isotropic - invProp" + def test_order1_faces_invert_model(self): + self.name = "Face Inner Product - Isotropic - invert_model" self.location = "faces" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() def test_order3_faces(self): self.name = "Face Inner Product - Anisotropic" self.location = "faces" self.sigmaTest = 3 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order3_faces_invProp(self): - self.name = "Face Inner Product - Anisotropic - invProp" + def test_order3_faces_invert_model(self): + self.name = "Face Inner Product - Anisotropic - invert_model" self.location = "faces" self.sigmaTest = 3 - self.invProp = True + self.invert_model = True self.orderTest() def test_order6_faces(self): self.name = "Face Inner Product - Full Tensor" self.location = "faces" self.sigmaTest = 6 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order6_faces_invProp(self): - self.name = "Face Inner Product - Full Tensor - invProp" + def test_order6_faces_invert_model(self): + self.name = "Face Inner Product - Full Tensor - invert_model" self.location = "faces" self.sigmaTest = 6 - self.invProp = True + self.invert_model = True self.orderTest() diff --git a/tests/tree/test_tree.py b/tests/tree/test_tree.py index cd3de1967..b9e0249b3 100644 --- a/tests/tree/test_tree.py +++ b/tests/tree/test_tree.py @@ -21,8 +21,8 @@ def test_counts(self): self.assertEqual(M.nhFx, 4) self.assertEqual(M.nFx, 12) - self.assertTrue(np.allclose(M.vol.sum(), 1.0)) - # self.assertTrue(np.allclose(np.r_[M._areaFxFull, M._areaFyFull], M._deflationMatrix('F') * M.area) + self.assertTrue(np.allclose(M.cell_volumes.sum(), 1.0)) + # self.assertTrue(np.allclose(np.r_[M._areaFxFull, M._areaFyFull], M._deflationMatrix('F') * M.face_areas) def test_getitem(self): M = discretize.TreeMesh([4, 4]) @@ -88,7 +88,7 @@ def test_faceDiv(self): hx, hy = np.r_[1.0, 2, 3, 4], np.r_[5.0, 6, 7, 8] T = discretize.TreeMesh([hx, hy], levels=2) T.refine(lambda xc: 2) - # T.plotGrid(show_it=True) + # T.plot_grid(show_it=True) M = discretize.TensorMesh([hx, hy]) self.assertEqual(M.nC, T.nC) self.assertEqual(M.nF, T.nF) @@ -98,15 +98,15 @@ def test_faceDiv(self): self.assertEqual(M.nEx, T.nEx) self.assertEqual(M.nEy, T.nEy) - self.assertTrue(np.allclose(M.area, T.permuteF * T.area)) - self.assertTrue(np.allclose(M.edge, T.permuteE * T.edge)) - self.assertTrue(np.allclose(M.vol, T.permuteCC * T.vol)) + self.assertTrue(np.allclose(M.face_areas, T.permute_faces * T.face_areas)) + self.assertTrue(np.allclose(M.edge_lengths, T.permute_edges * T.edge_lengths)) + self.assertTrue(np.allclose(M.cell_volumes, T.permute_cells * T.cell_volumes)) - # plt.subplot(211).spy(M.faceDiv) - # plt.subplot(212).spy(T.permuteCC*T.faceDiv*T.permuteF.T) + # plt.subplot(211).spy(M.face_divergence) + # plt.subplot(212).spy(T.permute_cells*T.face_divergence*T.permute_faces.T) # plt.show() - self.assertEqual((M.faceDiv - T.permuteCC * T.faceDiv * T.permuteF.T).nnz, 0) + self.assertEqual((M.face_divergence - T.permute_cells * T.face_divergence * T.permute_faces.T).nnz, 0) def test_serialization(self): hx, hy = np.r_[1.0, 2, 3, 4], np.r_[5.0, 6, 7, 8] @@ -134,26 +134,26 @@ def test_counts(self): levels = np.array([1, 2]) M.insert_cells(points, levels) M.number() - # M.plotGrid(show_it=True) + # M.plot_grid(show_it=True) self.assertEqual(M.nhFx, 4) self.assertTrue(M.nFx, 19) self.assertTrue(M.nC, 15) - self.assertTrue(np.allclose(M.vol.sum(), 1.0)) + self.assertTrue(np.allclose(M.cell_volumes.sum(), 1.0)) - # self.assertTrue(np.allclose(M._areaFxFull, (M._deflationMatrix('F') * M.area)[:M.ntFx])) - # self.assertTrue(np.allclose(M._areaFyFull, (M._deflationMatrix('F') * M.area)[M.ntFx:(M.ntFx+M.ntFy)]) - # self.assertTrue(np.allclose(M._areaFzFull, (M._deflationMatrix('F') * M.area)[(M.ntFx+M.ntFy):]) + # self.assertTrue(np.allclose(M._areaFxFull, (M._deflationMatrix('F') * M.face_areas)[:M.ntFx])) + # self.assertTrue(np.allclose(M._areaFyFull, (M._deflationMatrix('F') * M.face_areas)[M.ntFx:(M.ntFx+M.ntFy)]) + # self.assertTrue(np.allclose(M._areaFzFull, (M._deflationMatrix('F') * M.face_areas)[(M.ntFx+M.ntFy):]) - # self.assertTrue(np.allclose(M._edgeExFull, (M._deflationMatrix('E') * M.edge)[:M.ntEx]) - # self.assertTrue(np.allclose(M._edgeEyFull, (M._deflationMatrix('E') * M.edge)[M.ntEx:(M.ntEx+M.ntEy)]) - # self.assertTrue(np.allclose(M._edgeEzFull, (M._deflationMatrix('E') * M.edge)[(M.ntEx+M.ntEy):])) + # self.assertTrue(np.allclose(M._edgeExFull, (M._deflationMatrix('E') * M.edge_lengths)[:M.ntEx]) + # self.assertTrue(np.allclose(M._edgeEyFull, (M._deflationMatrix('E') * M.edge_lengths)[M.ntEx:(M.ntEx+M.ntEy)]) + # self.assertTrue(np.allclose(M._edgeEzFull, (M._deflationMatrix('E') * M.edge_lengths)[(M.ntEx+M.ntEy):])) def test_faceDiv(self): hx, hy, hz = np.r_[1.0, 2, 3, 4], np.r_[5.0, 6, 7, 8], np.r_[9.0, 10, 11, 12] M = discretize.TreeMesh([hx, hy, hz], levels=2) M.refine(lambda xc: 2) - # M.plotGrid(show_it=True) + # M.plot_grid(show_it=True) Mr = discretize.TensorMesh([hx, hy, hz]) self.assertEqual(M.nC, Mr.nC) self.assertEqual(M.nF, Mr.nF) @@ -163,21 +163,21 @@ def test_faceDiv(self): self.assertEqual(M.nEx, Mr.nEx) self.assertEqual(M.nEy, Mr.nEy) - self.assertTrue(np.allclose(Mr.area, M.permuteF * M.area)) - self.assertTrue(np.allclose(Mr.edge, M.permuteE * M.edge)) - self.assertTrue(np.allclose(Mr.vol, M.permuteCC * M.vol)) + self.assertTrue(np.allclose(Mr.face_areas, M.permute_faces * M.face_areas)) + self.assertTrue(np.allclose(Mr.edge_lengths, M.permute_edges * M.edge_lengths)) + self.assertTrue(np.allclose(Mr.cell_volumes, M.permute_cells * M.cell_volumes)) - A = Mr.faceDiv - M.permuteCC * M.faceDiv * M.permuteF.T + A = Mr.face_divergence - M.permute_cells * M.face_divergence * M.permute_faces.T self.assertTrue(np.allclose(A.data, 0)) - def test_edgeCurl(self): + def test_edge_curl(self): hx, hy, hz = np.r_[1.0, 2, 3, 4], np.r_[5.0, 6, 7, 8], np.r_[9.0, 10, 11, 12] M = discretize.TreeMesh([hx, hy, hz], levels=2) M.refine(lambda xc: 2) Mr = discretize.TensorMesh([hx, hy, hz]) - A = Mr.edgeCurl - M.permuteF * M.edgeCurl * M.permuteE.T + A = Mr.edge_curl - M.permute_faces * M.edge_curl * M.permute_edges.T self.assertTrue(len(A.data) == 0 or np.allclose(A.data, 0)) @@ -187,17 +187,17 @@ def test_faceInnerProduct(self): M = discretize.TreeMesh([hx, hy, hz], levels=2) M.refine(lambda xc: 2) - # M.plotGrid(show_it=True) + # M.plot_grid(show_it=True) Mr = discretize.TensorMesh([hx, hy, hz]) - # print(M.nC, M.nF, M.getFaceInnerProduct().shape, M.permuteF.shape) + # print(M.nC, M.nF, M.get_face_inner_product().shape, M.permute_faces.shape) A_face = ( - Mr.getFaceInnerProduct() - - M.permuteF * M.getFaceInnerProduct() * M.permuteF.T + Mr.get_face_inner_product() + - M.permute_faces * M.get_face_inner_product() * M.permute_faces.T ) A_edge = ( - Mr.getEdgeInnerProduct() - - M.permuteE * M.getEdgeInnerProduct() * M.permuteE.T + Mr.get_edge_inner_product() + - M.permute_edges * M.get_edge_inner_product() * M.permute_edges.T ) self.assertTrue(len(A_face.data) == 0 or np.allclose(A_face.data, 0)) @@ -210,15 +210,15 @@ def test_VectorIdenties(self): Mr = discretize.TensorMesh([hx, hy, hz]) M.refine(2) # Why wasn't this here before? - self.assertTrue(np.allclose((M.faceDiv * M.edgeCurl).data, 0)) + self.assertTrue(np.allclose((M.face_divergence * M.edge_curl).data, 0)) hx, hy, hz = np.r_[1.0, 2, 3, 4], np.r_[5.0, 6, 7, 8], np.r_[9.0, 10, 11, 12] M = discretize.TreeMesh([hx, hy, hz], levels=2) Mr = discretize.TensorMesh([hx, hy, hz]) M.refine(2) - A1 = M.faceDiv * M.edgeCurl - A2 = Mr.faceDiv * Mr.edgeCurl + A1 = M.face_divergence * M.edge_curl + A2 = Mr.face_divergence * Mr.edge_curl self.assertTrue(len(A1.data) == 0 or np.allclose(A1.data, 0)) self.assertTrue(len(A2.data) == 0 or np.allclose(A2.data, 0)) @@ -364,12 +364,12 @@ def function(cell): def test_fx(self): r = np.random.rand(self.M.nFx) - P = self.M.getInterpolationMat(self.M.gridFx, "Fx") + P = self.M.get_interpolation_matrix(self.M.gridFx, "Fx") self.assertLess(np.abs(P[:, : self.M.nFx] * r - r).max(), TOL) def test_fy(self): r = np.random.rand(self.M.nFy) - P = self.M.getInterpolationMat(self.M.gridFy, "Fy") + P = self.M.get_interpolation_matrix(self.M.gridFy, "Fy") self.assertLess(np.abs(P[:, self.M.nFx :] * r - r).max(), TOL) @@ -389,41 +389,41 @@ def function(cell): M = discretize.TreeMesh([16, 16, 16], levels=4) M.refine(function) - # M.plotGrid(show_it=True) + # M.plot_grid(show_it=True) self.M = M def test_Fx(self): r = np.random.rand(self.M.nFx) - P = self.M.getInterpolationMat(self.M.gridFx, "Fx") + P = self.M.get_interpolation_matrix(self.M.gridFx, "Fx") self.assertLess(np.abs(P[:, : self.M.nFx] * r - r).max(), TOL) def test_Fy(self): r = np.random.rand(self.M.nFy) - P = self.M.getInterpolationMat(self.M.gridFy, "Fy") + P = self.M.get_interpolation_matrix(self.M.gridFy, "Fy") self.assertLess( np.abs(P[:, self.M.nFx : (self.M.nFx + self.M.nFy)] * r - r).max(), TOL ) def test_Fz(self): r = np.random.rand(self.M.nFz) - P = self.M.getInterpolationMat(self.M.gridFz, "Fz") + P = self.M.get_interpolation_matrix(self.M.gridFz, "Fz") self.assertLess(np.abs(P[:, (self.M.nFx + self.M.nFy) :] * r - r).max(), TOL) def test_Ex(self): r = np.random.rand(self.M.nEx) - P = self.M.getInterpolationMat(self.M.gridEx, "Ex") + P = self.M.get_interpolation_matrix(self.M.gridEx, "Ex") self.assertLess(np.abs(P[:, : self.M.nEx] * r - r).max(), TOL) def test_Ey(self): r = np.random.rand(self.M.nEy) - P = self.M.getInterpolationMat(self.M.gridEy, "Ey") + P = self.M.get_interpolation_matrix(self.M.gridEy, "Ey") self.assertLess( np.abs(P[:, self.M.nEx : (self.M.nEx + self.M.nEy)] * r - r).max(), TOL ) def test_Ez(self): r = np.random.rand(self.M.nEz) - P = self.M.getInterpolationMat(self.M.gridEz, "Ez") + P = self.M.get_interpolation_matrix(self.M.gridEz, "Ez") self.assertLess(np.abs(P[:, (self.M.nEx + self.M.nEy) :] * r - r).max(), TOL) diff --git a/tests/tree/test_tree_innerproduct_derivs.py b/tests/tree/test_tree_innerproduct_derivs.py index 4d1ff3bf0..ff29c8488 100644 --- a/tests/tree/test_tree_innerproduct_derivs.py +++ b/tests/tree/test_tree_innerproduct_derivs.py @@ -3,9 +3,9 @@ import discretize -def doTestFace(h, rep, fast, meshType, invProp=False, invMat=False): +def doTestFace(h, rep, fast, meshType, invert_model=False, invert_matrix=False): if meshType == "Curv": - hRect = discretize.utils.exampleLrmGrid(h, "rotate") + hRect = discretize.utils.example_curvilinear_grid(h, "rotate") mesh = discretize.CurvilinearMesh(hRect) elif meshType == "Tree": mesh = discretize.TreeMesh(h, levels=3) @@ -16,9 +16,9 @@ def doTestFace(h, rep, fast, meshType, invProp=False, invMat=False): sig = np.random.rand(1) if rep == 0 else np.random.rand(mesh.nC * rep) def fun(sig): - M = mesh.getFaceInnerProduct(sig, invProp=invProp, invMat=invMat) - Md = mesh.getFaceInnerProductDeriv( - sig, invProp=invProp, invMat=invMat, doFast=fast + M = mesh.get_face_inner_product(sig, invert_model=invert_model, invert_matrix=invert_matrix) + Md = mesh.get_face_inner_product_deriv( + sig, invert_model=invert_model, invert_matrix=invert_matrix, do_fast=fast ) return M * v, Md(v) @@ -28,14 +28,14 @@ def fun(sig): h, rep, fast, - ("harmonic" if invProp and invMat else "standard"), + ("harmonic" if invert_model and invert_matrix else "standard"), ) - return discretize.tests.checkDerivative(fun, sig, num=5, plotIt=False) + return discretize.tests.check_derivative(fun, sig, num=5, plotIt=False) -def doTestEdge(h, rep, fast, meshType, invProp=False, invMat=False): +def doTestEdge(h, rep, fast, meshType, invert_model=False, invert_matrix=False): if meshType == "Curv": - hRect = discretize.utils.exampleLrmGrid(h, "rotate") + hRect = discretize.utils.example_curvilinear_grid(h, "rotate") mesh = discretize.CurvilinearMesh(hRect) elif meshType == "Tree": mesh = discretize.TreeMesh(h, levels=3) @@ -46,9 +46,9 @@ def doTestEdge(h, rep, fast, meshType, invProp=False, invMat=False): sig = np.random.rand(1) if rep == 0 else np.random.rand(mesh.nC * rep) def fun(sig): - M = mesh.getEdgeInnerProduct(sig, invProp=invProp, invMat=invMat) - Md = mesh.getEdgeInnerProductDeriv( - sig, invProp=invProp, invMat=invMat, doFast=fast + M = mesh.get_edge_inner_product(sig, invert_model=invert_model, invert_matrix=invert_matrix) + Md = mesh.get_edge_inner_product_deriv( + sig, invert_model=invert_model, invert_matrix=invert_matrix, do_fast=fast ) return M * v, Md(v) @@ -58,9 +58,9 @@ def fun(sig): h, rep, fast, - ("harmonic" if invProp and invMat else "standard"), + ("harmonic" if invert_model and invert_matrix else "standard"), ) - return discretize.tests.checkDerivative(fun, sig, num=5, plotIt=False) + return discretize.tests.check_derivative(fun, sig, num=5, plotIt=False) class TestInnerProductsDerivsTensor(unittest.TestCase): diff --git a/tests/tree/test_tree_interpolation.py b/tests/tree/test_tree_interpolation.py index 9ecde8898..835a800f4 100644 --- a/tests/tree/test_tree_interpolation.py +++ b/tests/tree/test_tree_interpolation.py @@ -68,26 +68,26 @@ def getError(self): if "F" in self.type: Fc = cartF2(self.M, funX, funY) - grid = self.M.projectFaceVector(Fc) + grid = self.M.project_face_vector(Fc) elif "E" in self.type: Ec = cartE2(self.M, funX, funY) - grid = self.M.projectEdgeVector(Ec) + grid = self.M.project_edge_vector(Ec) elif "CC" == self.type: grid = call2(funX, self.M.gridCC) elif "N" == self.type: grid = call2(funX, self.M.gridN) - comp = self.M.getInterpolationMat(self.LOCS, self.type) * grid + comp = self.M.get_interpolation_matrix(self.LOCS, self.type) * grid err = np.linalg.norm((comp - ana), np.inf) if plotIt: import matplotlib.pyplot as plt ax = plt.subplot(211) - self.M.plotGrid(ax=ax) + self.M.plot_grid(ax=ax) plt.plot(self.LOCS[:, 0], self.LOCS[:, 1], "mx") # ax = plt.subplot(111) - # self.M.plotImage(call2(funX, self.M.gridCC), ax=ax) + # self.M.plot_image(call2(funX, self.M.gridCC), ax=ax) ax = plt.subplot(212) plt.plot(self.LOCS[:, 1], comp, "bx") plt.plot(self.LOCS[:, 1], ana, "ro") @@ -153,16 +153,16 @@ def getError(self): if "F" in self.type: Fc = cartF3(self.M, funX, funY, funZ) - grid = self.M.projectFaceVector(Fc) + grid = self.M.project_face_vector(Fc) elif "E" in self.type: Ec = cartE3(self.M, funX, funY, funZ) - grid = self.M.projectEdgeVector(Ec) + grid = self.M.project_edge_vector(Ec) elif "CC" == self.type: grid = call3(funX, self.M.gridCC) elif "N" == self.type: grid = call3(funX, self.M.gridN) - A = self.M.getInterpolationMat(self.LOCS, self.type) + A = self.M.get_interpolation_matrix(self.LOCS, self.type) comp = A * grid err = np.linalg.norm((comp - ana), np.inf) diff --git a/tests/tree/test_tree_io.py b/tests/tree/test_tree_io.py index 437ac5db8..91689b94c 100644 --- a/tests/tree/test_tree_io.py +++ b/tests/tree/test_tree_io.py @@ -27,9 +27,9 @@ def test_UBC3Dfiles(self): # Make a vector vec = np.arange(mesh.nC) # Write and read - mesh.writeUBC("temp.msh", {"arange.txt": vec}) - meshUBC = discretize.TreeMesh.readUBC("temp.msh") - vecUBC = meshUBC.readModelUBC("arange.txt") + mesh.write_UBC("temp.msh", {"arange.txt": vec}) + meshUBC = discretize.TreeMesh.read_UBC("temp.msh") + vecUBC = meshUBC.read_model_UBC("arange.txt") self.assertEqual(mesh.nC, meshUBC.nC) self.assertEqual(mesh.__str__(), meshUBC.__str__()) @@ -38,8 +38,8 @@ def test_UBC3Dfiles(self): self.assertTrue(np.allclose(np.array(mesh.h), np.array(meshUBC.h))) # Write it again with another IO function - mesh.writeModelUBC(["arange.txt"], [vec]) - vecUBC2 = mesh.readModelUBC("arange.txt") + mesh.write_model_UBC(["arange.txt"], [vec]) + vecUBC2 = mesh.read_model_UBC("arange.txt") self.assertTrue(np.allclose(vec, vecUBC2)) print("IO of UBC octree files is working") @@ -59,9 +59,9 @@ def refine(cell): mesh0.refine(refine) mod0 = np.arange(mesh0.nC) - mesh0.writeUBC("tmp.msh", {"arange.txt": mod0}) - mesh1 = discretize.TreeMesh.readUBC("tmp.msh") - mod1 = mesh1.readModelUBC("arange.txt") + mesh0.write_UBC("tmp.msh", {"arange.txt": mod0}) + mesh1 = discretize.TreeMesh.read_UBC("tmp.msh") + mod1 = mesh1.read_model_UBC("arange.txt") self.assertEqual(mesh0.nC, mesh1.nC) self.assertEqual(mesh0.__str__(), mesh1.__str__()) @@ -75,7 +75,7 @@ def refine(cell): def test_VTUfiles(self): mesh = self.mesh vec = np.arange(mesh.nC) - mesh.writeVTK("temp.vtu", {"arange": vec}) + mesh.write_vtk("temp.vtu", {"arange": vec}) print("Writing of VTU files is working") os.remove("temp.vtu") diff --git a/tests/tree/test_tree_operators.py b/tests/tree/test_tree_operators.py index fba3c48ea..8293d80d5 100644 --- a/tests/tree/test_tree_operators.py +++ b/tests/tree/test_tree_operators.py @@ -50,9 +50,9 @@ def getError(self): fy = lambda x, y: -2 * np.pi * np.sin(2 * np.pi * y) * np.cos(2 * np.pi * x) phi = call2(sol, self.M.gridCC) - gradF = self.M.cellGrad * phi + gradF = self.M.cell_gradient * phi Fc = cartF2(self.M, fx, fy) - gradF_ana = self.M.projectFaceVector(Fc) + gradF_ana = self.M.project_face_vector(Fc) err = np.linalg.norm((gradF - gradF_ana), np.inf) @@ -100,9 +100,9 @@ def getError(self): * np.sin(2 * np.pi * z) ) phi = call3(sol, self.M.gridCC) - gradF = self.M.cellGrad * phi + gradF = self.M.cell_gradient * phi Fc = cartF3(self.M, fx, fy, fz) - gradF_ana = self.M.projectFaceVector(Fc) + gradF_ana = self.M.project_face_vector(Fc) err = np.linalg.norm((gradF - gradF_ana), np.inf) @@ -127,15 +127,15 @@ def getError(self): Fx = call2(fx, self.M.gridFx) Fy = call2(fy, self.M.gridFy) - divFx = self.M.faceDivx.dot(Fx) - divFy = self.M.faceDivy.dot(Fy) + divFx = self.M.face_x_divergence.dot(Fx) + divFy = self.M.face_y_divergence.dot(Fy) divF = divFx + divFy divF_ana = call2(sol, self.M.gridCC) err = np.linalg.norm((divF - divF_ana), np.inf) - # self.M.plotImage(divF-divF_ana, show_it=True) + # self.M.plot_image(divF-divF_ana, show_it=True) return err @@ -160,9 +160,9 @@ def getError(self): ) Fc = cartF3(self.M, fx, fy, fz) - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) - divF = self.M.faceDiv.dot(F) + divF = self.M.face_divergence.dot(F) divF_ana = call3(sol, self.M.gridCC) return np.linalg.norm((divF - divF_ana), np.inf) @@ -192,16 +192,16 @@ def getError(self): Fx = call3(fx, self.M.gridFx) Fy = call3(fy, self.M.gridFy) Fz = call3(fz, self.M.gridFz) - divFx = self.M.faceDivx.dot(Fx) - divFy = self.M.faceDivy.dot(Fy) - divFz = self.M.faceDivz.dot(Fz) + divFx = self.M.face_x_divergence.dot(Fx) + divFy = self.M.face_y_divergence.dot(Fy) + divFz = self.M.face_z_divergence.dot(Fz) divF = divFx + divFy + divFz divF_ana = call3(sol, self.M.gridCC) err = np.linalg.norm((divF - divF_ana), np.inf) - # self.M.plotImage(divF-divF_ana, show_it=True) + # self.M.plot_image(divF-divF_ana, show_it=True) return err @@ -229,15 +229,15 @@ def getError(self): solZ = lambda x, y, z: 2 * np.pi * np.sin(2 * np.pi * y) Ec = cartE3(self.M, funX, funY, funZ) - E = self.M.projectEdgeVector(Ec) + E = self.M.project_edge_vector(Ec) Fc = cartF3(self.M, solX, solY, solZ) - curlE_ana = self.M.projectFaceVector(Fc) + curlE_ana = self.M.project_face_vector(Fc) - curlE = self.M.edgeCurl.dot(E) + curlE = self.M.edge_curl.dot(E) err = np.linalg.norm((curlE - curlE_ana), np.inf) - # err = np.linalg.norm((curlE - curlE_ana)*self.M.area, 2) + # err = np.linalg.norm((curlE - curlE_ana)*self.M.face_areas, 2) return err @@ -261,10 +261,10 @@ def getError(self): solZ = lambda x, y, z: -np.sin(z) phi = call3(fun, self.M.gridN) - gradE = self.M.nodalGrad.dot(phi) + gradE = self.M.nodal_gradient.dot(phi) Ec = cartE3(self.M, solX, solY, solZ) - gradE_ana = self.M.projectEdgeVector(Ec) + gradE_ana = self.M.project_edge_vector(Ec) err = np.linalg.norm((gradE - gradE_ana), np.inf) @@ -290,10 +290,10 @@ def getError(self): solY = lambda x, y: -np.sin(y) phi = call2(fun, self.M.gridN) - gradE = self.M.nodalGrad.dot(phi) + gradE = self.M.nodal_gradient.dot(phi) Ec = cartE2(self.M, solX, solY) - gradE_ana = self.M.projectEdgeVector(Ec) + gradE_ana = self.M.project_edge_vector(Ec) err = np.linalg.norm((gradE - gradE_ana), np.inf) @@ -351,28 +351,28 @@ def getError(self): Ec = np.vstack( (cart(self.M.gridEx), cart(self.M.gridEy), cart(self.M.gridEz)) ) - E = self.M.projectEdgeVector(Ec) + E = self.M.project_edge_vector(Ec) - if self.invProp: - A = self.M.getEdgeInnerProduct( - discretize.utils.invPropertyTensor(self.M, sigma), invProp=True + if self.invert_model: + A = self.M.get_edge_inner_product( + discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True ) else: - A = self.M.getEdgeInnerProduct(sigma) + A = self.M.get_edge_inner_product(sigma) numeric = E.T.dot(A.dot(E)) elif self.location == "faces": cart = lambda g: np.c_[call(ex, g), call(ey, g), call(ez, g)] Fc = np.vstack( (cart(self.M.gridFx), cart(self.M.gridFy), cart(self.M.gridFz)) ) - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) - if self.invProp: - A = self.M.getFaceInnerProduct( - discretize.utils.invPropertyTensor(self.M, sigma), invProp=True + if self.invert_model: + A = self.M.get_face_inner_product( + discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True ) else: - A = self.M.getFaceInnerProduct(sigma) + A = self.M.get_face_inner_product(sigma) numeric = F.T.dot(A.dot(F)) err = np.abs(numeric - analytic) @@ -382,84 +382,84 @@ def test_order1_edges(self): self.name = "Edge Inner Product - Isotropic" self.location = "edges" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_edges_invProp(self): - self.name = "Edge Inner Product - Isotropic - invProp" + def test_order1_edges_invert_model(self): + self.name = "Edge Inner Product - Isotropic - invert_model" self.location = "edges" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() def test_order3_edges(self): self.name = "Edge Inner Product - Anisotropic" self.location = "edges" self.sigmaTest = 3 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order3_edges_invProp(self): - self.name = "Edge Inner Product - Anisotropic - invProp" + def test_order3_edges_invert_model(self): + self.name = "Edge Inner Product - Anisotropic - invert_model" self.location = "edges" self.sigmaTest = 3 - self.invProp = True + self.invert_model = True self.orderTest() def test_order6_edges(self): self.name = "Edge Inner Product - Full Tensor" self.location = "edges" self.sigmaTest = 6 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order6_edges_invProp(self): - self.name = "Edge Inner Product - Full Tensor - invProp" + def test_order6_edges_invert_model(self): + self.name = "Edge Inner Product - Full Tensor - invert_model" self.location = "edges" self.sigmaTest = 6 - self.invProp = True + self.invert_model = True self.orderTest() def test_order1_faces(self): self.name = "Face Inner Product - Isotropic" self.location = "faces" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_faces_invProp(self): - self.name = "Face Inner Product - Isotropic - invProp" + def test_order1_faces_invert_model(self): + self.name = "Face Inner Product - Isotropic - invert_model" self.location = "faces" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() def test_order3_faces(self): self.name = "Face Inner Product - Anisotropic" self.location = "faces" self.sigmaTest = 3 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order3_faces_invProp(self): - self.name = "Face Inner Product - Anisotropic - invProp" + def test_order3_faces_invert_model(self): + self.name = "Face Inner Product - Anisotropic - invert_model" self.location = "faces" self.sigmaTest = 3 - self.invProp = True + self.invert_model = True self.orderTest() def test_order6_faces(self): self.name = "Face Inner Product - Full Tensor" self.location = "faces" self.sigmaTest = 6 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order6_faces_invProp(self): - self.name = "Face Inner Product - Full Tensor - invProp" + def test_order6_faces_invert_model(self): + self.name = "Face Inner Product - Full Tensor - invert_model" self.location = "faces" self.sigmaTest = 6 - self.invProp = True + self.invert_model = True self.orderTest() @@ -496,25 +496,25 @@ def getError(self): if self.location == "edges": cart = lambda g: np.c_[call(ex, g), call(ey, g)] Ec = np.vstack((cart(self.M.gridEx), cart(self.M.gridEy))) - E = self.M.projectEdgeVector(Ec) - if self.invProp: - A = self.M.getEdgeInnerProduct( - discretize.utils.invPropertyTensor(self.M, sigma), invProp=True + E = self.M.project_edge_vector(Ec) + if self.invert_model: + A = self.M.get_edge_inner_product( + discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True ) else: - A = self.M.getEdgeInnerProduct(sigma) + A = self.M.get_edge_inner_product(sigma) numeric = E.T.dot(A.dot(E)) elif self.location == "faces": cart = lambda g: np.c_[call(ex, g), call(ey, g)] Fc = np.vstack((cart(self.M.gridFx), cart(self.M.gridFy))) - F = self.M.projectFaceVector(Fc) + F = self.M.project_face_vector(Fc) - if self.invProp: - A = self.M.getFaceInnerProduct( - discretize.utils.invPropertyTensor(self.M, sigma), invProp=True + if self.invert_model: + A = self.M.get_face_inner_product( + discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True ) else: - A = self.M.getFaceInnerProduct(sigma) + A = self.M.get_face_inner_product(sigma) numeric = F.T.dot(A.dot(F)) err = np.abs(numeric - analytic) @@ -524,84 +524,84 @@ def test_order1_edges(self): self.name = "2D Edge Inner Product - Isotropic" self.location = "edges" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_edges_invProp(self): - self.name = "2D Edge Inner Product - Isotropic - invProp" + def test_order1_edges_invert_model(self): + self.name = "2D Edge Inner Product - Isotropic - invert_model" self.location = "edges" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() def test_order3_edges(self): self.name = "2D Edge Inner Product - Anisotropic" self.location = "edges" self.sigmaTest = 2 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order3_edges_invProp(self): - self.name = "2D Edge Inner Product - Anisotropic - invProp" + def test_order3_edges_invert_model(self): + self.name = "2D Edge Inner Product - Anisotropic - invert_model" self.location = "edges" self.sigmaTest = 2 - self.invProp = True + self.invert_model = True self.orderTest() # def test_order6_edges(self): # self.name = "2D Edge Inner Product - Full Tensor" # self.location = 'edges' # self.sigmaTest = 3 - # self.invProp = False + # self.invert_model = False # self.orderTest() - # def test_order6_edges_invProp(self): - # self.name = "2D Edge Inner Product - Full Tensor - invProp" + # def test_order6_edges_invert_model(self): + # self.name = "2D Edge Inner Product - Full Tensor - invert_model" # self.location = 'edges' # self.sigmaTest = 3 - # self.invProp = True + # self.invert_model = True # self.orderTest() def test_order1_faces(self): self.name = "2D Face Inner Product - Isotropic" self.location = "faces" self.sigmaTest = 1 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order1_faces_invProp(self): - self.name = "2D Face Inner Product - Isotropic - invProp" + def test_order1_faces_invert_model(self): + self.name = "2D Face Inner Product - Isotropic - invert_model" self.location = "faces" self.sigmaTest = 1 - self.invProp = True + self.invert_model = True self.orderTest() def test_order2_faces(self): self.name = "2D Face Inner Product - Anisotropic" self.location = "faces" self.sigmaTest = 2 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order2_faces_invProp(self): - self.name = "2D Face Inner Product - Anisotropic - invProp" + def test_order2_faces_invert_model(self): + self.name = "2D Face Inner Product - Anisotropic - invert_model" self.location = "faces" self.sigmaTest = 2 - self.invProp = True + self.invert_model = True self.orderTest() def test_order3_faces(self): self.name = "2D Face Inner Product - Full Tensor" self.location = "faces" self.sigmaTest = 3 - self.invProp = False + self.invert_model = False self.orderTest() - def test_order3_faces_invProp(self): - self.name = "2D Face Inner Product - Full Tensor - invProp" + def test_order3_faces_invert_model(self): + self.name = "2D Face Inner Product - Full Tensor - invert_model" self.location = "faces" self.sigmaTest = 3 - self.invProp = True + self.invert_model = True self.orderTest() From 9e0b8ecadfab494906e5e6ca22b229371c890469 Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Fri, 27 Jan 2023 19:10:54 -0800 Subject: [PATCH 10/16] black formatting --- examples/plot_dc_resistivity.py | 8 ++- tests/base/test_tensor_innerproduct.py | 12 ++-- tests/base/test_tensor_innerproduct_derivs.py | 58 ++++++++++++++----- tests/cyl/test_cyl.py | 16 +++-- tests/cyl/test_cyl3D.py | 31 ++++++---- tests/cyl/test_cyl_innerproducts.py | 32 +++++++--- tests/tree/test_tree.py | 8 ++- tests/tree/test_tree_innerproduct_derivs.py | 8 ++- tests/tree/test_tree_operators.py | 12 ++-- tutorials/inner_products/3_calculus.py | 4 +- tutorials/inner_products/4_advanced.py | 8 ++- 11 files changed, 145 insertions(+), 52 deletions(-) diff --git a/examples/plot_dc_resistivity.py b/examples/plot_dc_resistivity.py index 3f227afed..06e176f4d 100644 --- a/examples/plot_dc_resistivity.py +++ b/examples/plot_dc_resistivity.py @@ -14,13 +14,17 @@ def run(plotIt=True): # Step1: Generate Tensor and Curvilinear Mesh sz = [40, 40] tM = discretize.TensorMesh(sz) - rM = discretize.CurvilinearMesh(discretize.utils.example_curvilinear_grid(sz, "rotate")) + rM = discretize.CurvilinearMesh( + discretize.utils.example_curvilinear_grid(sz, "rotate") + ) # Step2: Direct Current (DC) operator def DCfun(mesh, pts): D = mesh.face_divergence sigma = 1e-2 * np.ones(mesh.nC) - MsigI = mesh.get_face_inner_product(sigma, invert_model=True, invert_matrix=True) + MsigI = mesh.get_face_inner_product( + sigma, invert_model=True, invert_matrix=True + ) A = -D * MsigI * D.T A[-1, -1] /= mesh.cell_volumes[-1] # Remove null space rhs = np.zeros(mesh.nC) diff --git a/tests/base/test_tensor_innerproduct.py b/tests/base/test_tensor_innerproduct.py index bee36cca5..4865ed636 100644 --- a/tests/base/test_tensor_innerproduct.py +++ b/tests/base/test_tensor_innerproduct.py @@ -52,7 +52,8 @@ def getError(self): if self.invert_model: A = self.M.get_edge_inner_product( - discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True + discretize.utils.inverse_property_tensor(self.M, sigma), + invert_model=True, ) else: A = self.M.get_edge_inner_product(sigma) @@ -66,7 +67,8 @@ def getError(self): if self.invert_model: A = self.M.get_face_inner_product( - discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True + discretize.utils.inverse_property_tensor(self.M, sigma), + invert_model=True, ) else: A = self.M.get_face_inner_product(sigma) @@ -197,7 +199,8 @@ def getError(self): E = self.M.project_edge_vector(Ec) if self.invert_model: A = self.M.get_edge_inner_product( - discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True + discretize.utils.inverse_property_tensor(self.M, sigma), + invert_model=True, ) else: A = self.M.get_edge_inner_product(sigma) @@ -209,7 +212,8 @@ def getError(self): if self.invert_model: A = self.M.get_face_inner_product( - discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True + discretize.utils.inverse_property_tensor(self.M, sigma), + invert_model=True, ) else: A = self.M.get_face_inner_product(sigma) diff --git a/tests/base/test_tensor_innerproduct_derivs.py b/tests/base/test_tensor_innerproduct_derivs.py index 1b7eb9c9c..98440de24 100644 --- a/tests/base/test_tensor_innerproduct_derivs.py +++ b/tests/base/test_tensor_innerproduct_derivs.py @@ -6,7 +6,9 @@ class TestInnerProductsDerivsTensor(unittest.TestCase): - def doTestFace(self, h, rep, fast, meshType, invert_model=False, invert_matrix=False): + def doTestFace( + self, h, rep, fast, meshType, invert_model=False, invert_matrix=False + ): if meshType == "Curv": hRect = discretize.utils.example_curvilinear_grid(h, "rotate") mesh = discretize.CurvilinearMesh(hRect) @@ -20,9 +22,14 @@ def doTestFace(self, h, rep, fast, meshType, invert_model=False, invert_matrix=F sig = np.random.rand(1) if rep == 0 else np.random.rand(mesh.nC * rep) def fun(sig): - M = mesh.get_face_inner_product(sig, invert_model=invert_model, invert_matrix=invert_matrix) + M = mesh.get_face_inner_product( + sig, invert_model=invert_model, invert_matrix=invert_matrix + ) Md = mesh.get_face_inner_product_deriv( - sig, invert_model=invert_model, invert_matrix=invert_matrix, do_fast=fast + sig, + invert_model=invert_model, + invert_matrix=invert_matrix, + do_fast=fast, ) return M * v, Md(v) @@ -36,7 +43,9 @@ def fun(sig): ) return discretize.tests.check_derivative(fun, sig, num=5, plotIt=False) - def doTestEdge(self, h, rep, fast, meshType, invert_model=False, invert_matrix=False): + def doTestEdge( + self, h, rep, fast, meshType, invert_model=False, invert_matrix=False + ): if meshType == "Curv": hRect = discretize.utils.example_curvilinear_grid(h, "rotate") mesh = discretize.CurvilinearMesh(hRect) @@ -50,9 +59,14 @@ def doTestEdge(self, h, rep, fast, meshType, invert_model=False, invert_matrix=F sig = np.random.rand(1) if rep == 0 else np.random.rand(mesh.nC * rep) def fun(sig): - M = mesh.get_edge_inner_product(sig, invert_model=invert_model, invert_matrix=invert_matrix) + M = mesh.get_edge_inner_product( + sig, invert_model=invert_model, invert_matrix=invert_matrix + ) Md = mesh.get_edge_inner_product_deriv( - sig, invert_model=invert_model, invert_matrix=invert_matrix, do_fast=fast + sig, + invert_model=invert_model, + invert_matrix=invert_matrix, + do_fast=fast, ) return M * v, Md(v) @@ -176,42 +190,58 @@ def test_EdgeIP_3D_anisotropic_fast(self): def test_FaceIP_1D_float_fast_harmonic(self): self.assertTrue( - self.doTestFace([10], 0, True, "Tensor", invert_model=True, invert_matrix=True) + self.doTestFace( + [10], 0, True, "Tensor", invert_model=True, invert_matrix=True + ) ) def test_FaceIP_2D_float_fast_harmonic(self): self.assertTrue( - self.doTestFace([10, 4], 0, True, "Tensor", invert_model=True, invert_matrix=True) + self.doTestFace( + [10, 4], 0, True, "Tensor", invert_model=True, invert_matrix=True + ) ) def test_FaceIP_3D_float_fast_harmonic(self): self.assertTrue( - self.doTestFace([10, 4, 5], 0, True, "Tensor", invert_model=True, invert_matrix=True) + self.doTestFace( + [10, 4, 5], 0, True, "Tensor", invert_model=True, invert_matrix=True + ) ) def test_FaceIP_1D_isotropic_fast_harmonic(self): self.assertTrue( - self.doTestFace([10], 1, True, "Tensor", invert_model=True, invert_matrix=True) + self.doTestFace( + [10], 1, True, "Tensor", invert_model=True, invert_matrix=True + ) ) def test_FaceIP_2D_isotropic_fast_harmonic(self): self.assertTrue( - self.doTestFace([10, 4], 1, True, "Tensor", invert_model=True, invert_matrix=True) + self.doTestFace( + [10, 4], 1, True, "Tensor", invert_model=True, invert_matrix=True + ) ) def test_FaceIP_3D_isotropic_fast_harmonic(self): self.assertTrue( - self.doTestFace([10, 4, 5], 1, True, "Tensor", invert_model=True, invert_matrix=True) + self.doTestFace( + [10, 4, 5], 1, True, "Tensor", invert_model=True, invert_matrix=True + ) ) def test_FaceIP_2D_anisotropic_fast_harmonic(self): self.assertTrue( - self.doTestFace([10, 4], 2, True, "Tensor", invert_model=True, invert_matrix=True) + self.doTestFace( + [10, 4], 2, True, "Tensor", invert_model=True, invert_matrix=True + ) ) def test_FaceIP_3D_anisotropic_fast_harmonic(self): self.assertTrue( - self.doTestFace([10, 4, 5], 3, True, "Tensor", invert_model=True, invert_matrix=True) + self.doTestFace( + [10, 4, 5], 3, True, "Tensor", invert_model=True, invert_matrix=True + ) ) def test_FaceIP_2D_float_Curv(self): diff --git a/tests/cyl/test_cyl.py b/tests/cyl/test_cyl.py index 09d76641a..d03ef0a5e 100644 --- a/tests/cyl/test_cyl.py +++ b/tests/cyl/test_cyl.py @@ -90,7 +90,9 @@ def test_vol_simple(self): self.assertEqual(mesh.cell_volumes, np.pi) mesh = discretize.CylindricalMesh([2.0, 1.0, 1.0]) - self.assertTrue(np.all(mesh.cell_volumes == np.pi * np.r_[0.5**2, 1 - 0.5**2])) + self.assertTrue( + np.all(mesh.cell_volumes == np.pi * np.r_[0.5**2, 1 - 0.5**2]) + ) def test_gridSizes(self): self.assertEqual(self.mesh.gridCC.shape, (self.mesh.nC, 3)) @@ -154,7 +156,9 @@ def test_getInterpMatCartMesh_Cells(self): Pr = Mr.get_interpolation_matrix( np.c_[xr, np.ones(50) * -0.2, np.ones(50) * 0.5], "CC" ) - Pc = Mc.get_interpolation_matrix(np.c_[xc, np.zeros(50), np.ones(50) * 0.5], "CC") + Pc = Mc.get_interpolation_matrix( + np.c_[xc, np.zeros(50), np.ones(50) * 0.5], "CC" + ) Pc2r = Mc.get_interpolation_matrix_cartesian_mesh(Mr, "CC") assert np.abs(Pr * (Pc2r * mc) - Pc * mc).max() < 1e-3 @@ -171,8 +175,12 @@ def test_getInterpMatCartMesh_Cells2Nodes(self): Pr = Mr.get_interpolation_matrix( np.c_[xr, np.ones(50) * -0.2, np.ones(50) * 0.5], "N" ) - Pc = Mc.get_interpolation_matrix(np.c_[xc, np.zeros(50), np.ones(50) * 0.5], "CC") - Pc2r = Mc.get_interpolation_matrix_cartesian_mesh(Mr, "CC", location_type_to="N") + Pc = Mc.get_interpolation_matrix( + np.c_[xc, np.zeros(50), np.ones(50) * 0.5], "CC" + ) + Pc2r = Mc.get_interpolation_matrix_cartesian_mesh( + Mr, "CC", location_type_to="N" + ) assert np.abs(Pr * (Pc2r * mc) - Pc * mc).max() < 1e-3 diff --git a/tests/cyl/test_cyl3D.py b/tests/cyl/test_cyl3D.py index 47c133eaf..1c98b60ce 100644 --- a/tests/cyl/test_cyl3D.py +++ b/tests/cyl/test_cyl3D.py @@ -22,17 +22,19 @@ def test_areas(self): area = self.mesh.face_areas self.assertTrue(self.mesh.nF == len(area)) self.assertTrue( - area[: self.mesh.vnF[0]].sum() == 2 * np.pi * self.mesh.h[0] * self.mesh.h[2] + area[: self.mesh.vnF[0]].sum() + == 2 * np.pi * self.mesh.h[0] * self.mesh.h[2] ) self.assertTrue( np.all( - area[self.mesh.vnF[0] : self.mesh.vnF[1]] == self.mesh.h[0] * self.mesh.h[2] + area[self.mesh.vnF[0] : self.mesh.vnF[1]] + == self.mesh.h[0] * self.mesh.h[2] ) ) self.assertTrue( np.all( area[sum(self.mesh.vnF[:2]) :] - == np.pi * self.mesh.h[0]**2 / self.mesh.shape_cells[1] + == np.pi * self.mesh.h[0] ** 2 / self.mesh.shape_cells[1] ) ) @@ -43,13 +45,19 @@ def test_edges(self): self.assertTrue( np.all( self.mesh.edge_lengths[self.mesh.vnE[0] : sum(self.mesh.vnE[:2])] - == np.kron(np.ones(self.mesh.shape_cells[2] + 1), self.mesh.h[0] * self.mesh.h[1]) + == np.kron( + np.ones(self.mesh.shape_cells[2] + 1), + self.mesh.h[0] * self.mesh.h[1], + ) ) ) self.assertTrue( np.all( self.mesh.edge_lengths[self.mesh.vnE[0] : sum(self.mesh.vnE[:2])] - == np.kron(np.ones(self.mesh.shape_cells[2] + 1), self.mesh.h[0] * self.mesh.h[1]) + == np.kron( + np.ones(self.mesh.shape_cells[2] + 1), + self.mesh.h[0] * self.mesh.h[1], + ) ) ) self.assertTrue( @@ -60,11 +68,16 @@ def test_edges(self): ) def test_vol(self): - self.assertTrue(self.mesh.cell_volumes.sum() == np.pi * self.mesh.h[0]**2 * self.mesh.h[2]) + self.assertTrue( + self.mesh.cell_volumes.sum() == np.pi * self.mesh.h[0] ** 2 * self.mesh.h[2] + ) self.assertTrue( np.all( self.mesh.cell_volumes - == np.pi * self.mesh.h[0]**2 * self.mesh.h[2] / self.mesh.shape_cells[1] + == np.pi + * self.mesh.h[0] ** 2 + * self.mesh.h[2] + / self.mesh.shape_cells[1] ) ) @@ -175,9 +188,7 @@ def test_gridN(self): # Nodes self.assertTrue((mesh.nodes_x == [0.0, 0.5, 1.0]).all()) - self.assertTrue( - (mesh.nodes_y == 2 * np.pi * np.r_[0.0, 0.25, 0.5, 0.75]).all() - ) + self.assertTrue((mesh.nodes_y == 2 * np.pi * np.r_[0.0, 0.25, 0.5, 0.75]).all()) self.assertTrue((mesh.nodes_z == np.r_[0.0, 1.0]).all()) self.assertTrue( diff --git a/tests/cyl/test_cyl_innerproducts.py b/tests/cyl/test_cyl_innerproducts.py index ea6bad216..efcbe56fa 100644 --- a/tests/cyl/test_cyl_innerproducts.py +++ b/tests/cyl/test_cyl_innerproducts.py @@ -300,7 +300,9 @@ def fun(x): def test_FaceInnerProductIsotropicDerivInvProp(self): def fun(x): MfSig = self.mesh.get_face_inner_product(x, invert_model=True) - MfSigDeriv = self.mesh.get_face_inner_product_deriv(self.x0, invert_model=True) + MfSigDeriv = self.mesh.get_face_inner_product_deriv( + self.x0, invert_model=True + ) return MfSig * self.face_vec, MfSigDeriv(self.face_vec) print("Testing FaceInnerProduct Isotropic InvProp") @@ -311,7 +313,9 @@ def fun(x): def test_FaceInnerProductIsotropicDerivInvMat(self): def fun(x): MfSig = self.mesh.get_face_inner_product(x, invert_matrix=True) - MfSigDeriv = self.mesh.get_face_inner_product_deriv(self.x0, invert_matrix=True) + MfSigDeriv = self.mesh.get_face_inner_product_deriv( + self.x0, invert_matrix=True + ) return MfSig * self.face_vec, MfSigDeriv(self.face_vec) print("Testing FaceInnerProduct Isotropic InvMat") @@ -321,7 +325,9 @@ def fun(x): def test_FaceInnerProductIsotropicDerivInvPropInvMat(self): def fun(x): - MfSig = self.mesh.get_face_inner_product(x, invert_model=True, invert_matrix=True) + MfSig = self.mesh.get_face_inner_product( + x, invert_model=True, invert_matrix=True + ) MfSigDeriv = self.mesh.get_face_inner_product_deriv( self.x0, invert_model=True, invert_matrix=True ) @@ -346,7 +352,9 @@ def fun(x): def test_EdgeInnerProductIsotropicDerivInvProp(self): def fun(x): MeSig = self.mesh.get_edge_inner_product(x, invert_model=True) - MeSigDeriv = self.mesh.get_edge_inner_product_deriv(self.x0, invert_model=True) + MeSigDeriv = self.mesh.get_edge_inner_product_deriv( + self.x0, invert_model=True + ) return MeSig * self.edge_vec, MeSigDeriv(self.edge_vec) print("Testing EdgeInnerProduct Isotropic InvProp") @@ -357,7 +365,9 @@ def fun(x): def test_EdgeInnerProductIsotropicDerivInvMat(self): def fun(x): MeSig = self.mesh.get_edge_inner_product(x, invert_matrix=True) - MeSigDeriv = self.mesh.get_edge_inner_product_deriv(self.x0, invert_matrix=True) + MeSigDeriv = self.mesh.get_edge_inner_product_deriv( + self.x0, invert_matrix=True + ) return MeSig * self.edge_vec, MeSigDeriv(self.edge_vec) print("Testing EdgeInnerProduct Isotropic InvMat") @@ -367,7 +377,9 @@ def fun(x): def test_EdgeInnerProductIsotropicDerivInvPropInvMat(self): def fun(x): - MeSig = self.mesh.get_edge_inner_product(x, invert_model=True, invert_matrix=True) + MeSig = self.mesh.get_edge_inner_product( + x, invert_model=True, invert_matrix=True + ) MeSigDeriv = self.mesh.get_edge_inner_product_deriv( self.x0, invert_model=True, invert_matrix=True ) @@ -455,7 +467,9 @@ def fun(x): eye = sp.eye(self.mesh.nC) P = sp.vstack([sp.hstack([eye, zero, eye])]) - MfSig = self.mesh.get_face_inner_product(x, invert_model=True, invert_matrix=True) + MfSig = self.mesh.get_face_inner_product( + x, invert_model=True, invert_matrix=True + ) MfSigDeriv = self.mesh.get_face_inner_product_deriv( x0, invert_model=True, invert_matrix=True ) @@ -529,7 +543,9 @@ def fun(x): eye = sp.eye(self.mesh.nC) P = sp.vstack([sp.hstack([zero, eye, zero])]) - MeSig = self.mesh.get_edge_inner_product(x, invert_model=True, invert_matrix=True) + MeSig = self.mesh.get_edge_inner_product( + x, invert_model=True, invert_matrix=True + ) MeSigDeriv = self.mesh.get_edge_inner_product_deriv( x0, invert_model=True, invert_matrix=True ) diff --git a/tests/tree/test_tree.py b/tests/tree/test_tree.py index b9e0249b3..150284fb5 100644 --- a/tests/tree/test_tree.py +++ b/tests/tree/test_tree.py @@ -106,7 +106,13 @@ def test_faceDiv(self): # plt.subplot(212).spy(T.permute_cells*T.face_divergence*T.permute_faces.T) # plt.show() - self.assertEqual((M.face_divergence - T.permute_cells * T.face_divergence * T.permute_faces.T).nnz, 0) + self.assertEqual( + ( + M.face_divergence + - T.permute_cells * T.face_divergence * T.permute_faces.T + ).nnz, + 0, + ) def test_serialization(self): hx, hy = np.r_[1.0, 2, 3, 4], np.r_[5.0, 6, 7, 8] diff --git a/tests/tree/test_tree_innerproduct_derivs.py b/tests/tree/test_tree_innerproduct_derivs.py index ff29c8488..c03dc89f9 100644 --- a/tests/tree/test_tree_innerproduct_derivs.py +++ b/tests/tree/test_tree_innerproduct_derivs.py @@ -16,7 +16,9 @@ def doTestFace(h, rep, fast, meshType, invert_model=False, invert_matrix=False): sig = np.random.rand(1) if rep == 0 else np.random.rand(mesh.nC * rep) def fun(sig): - M = mesh.get_face_inner_product(sig, invert_model=invert_model, invert_matrix=invert_matrix) + M = mesh.get_face_inner_product( + sig, invert_model=invert_model, invert_matrix=invert_matrix + ) Md = mesh.get_face_inner_product_deriv( sig, invert_model=invert_model, invert_matrix=invert_matrix, do_fast=fast ) @@ -46,7 +48,9 @@ def doTestEdge(h, rep, fast, meshType, invert_model=False, invert_matrix=False): sig = np.random.rand(1) if rep == 0 else np.random.rand(mesh.nC * rep) def fun(sig): - M = mesh.get_edge_inner_product(sig, invert_model=invert_model, invert_matrix=invert_matrix) + M = mesh.get_edge_inner_product( + sig, invert_model=invert_model, invert_matrix=invert_matrix + ) Md = mesh.get_edge_inner_product_deriv( sig, invert_model=invert_model, invert_matrix=invert_matrix, do_fast=fast ) diff --git a/tests/tree/test_tree_operators.py b/tests/tree/test_tree_operators.py index 8293d80d5..62412372a 100644 --- a/tests/tree/test_tree_operators.py +++ b/tests/tree/test_tree_operators.py @@ -355,7 +355,8 @@ def getError(self): if self.invert_model: A = self.M.get_edge_inner_product( - discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True + discretize.utils.inverse_property_tensor(self.M, sigma), + invert_model=True, ) else: A = self.M.get_edge_inner_product(sigma) @@ -369,7 +370,8 @@ def getError(self): if self.invert_model: A = self.M.get_face_inner_product( - discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True + discretize.utils.inverse_property_tensor(self.M, sigma), + invert_model=True, ) else: A = self.M.get_face_inner_product(sigma) @@ -499,7 +501,8 @@ def getError(self): E = self.M.project_edge_vector(Ec) if self.invert_model: A = self.M.get_edge_inner_product( - discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True + discretize.utils.inverse_property_tensor(self.M, sigma), + invert_model=True, ) else: A = self.M.get_edge_inner_product(sigma) @@ -511,7 +514,8 @@ def getError(self): if self.invert_model: A = self.M.get_face_inner_product( - discretize.utils.inverse_property_tensor(self.M, sigma), invert_model=True + discretize.utils.inverse_property_tensor(self.M, sigma), + invert_model=True, ) else: A = self.M.get_face_inner_product(sigma) diff --git a/tutorials/inner_products/3_calculus.py b/tutorials/inner_products/3_calculus.py index cf3ff621a..0a3de5248 100644 --- a/tutorials/inner_products/3_calculus.py +++ b/tutorials/inner_products/3_calculus.py @@ -80,7 +80,9 @@ # Items required to perform u.T*(Mf*Gc*phi) Mf = mesh.get_face_inner_product() # Basic inner product matrix (faces) -mesh.set_cell_gradient_BC(["neumann", "dirichlet", "neumann"]) # Set boundary conditions +mesh.set_cell_gradient_BC( + ["neumann", "dirichlet", "neumann"] +) # Set boundary conditions Gc = mesh.cell_gradient # Cells to faces gradient # Plot Sparse Representation diff --git a/tutorials/inner_products/4_advanced.py b/tutorials/inner_products/4_advanced.py index 7b98c7513..8f97d1641 100644 --- a/tutorials/inner_products/4_advanced.py +++ b/tutorials/inner_products/4_advanced.py @@ -85,7 +85,9 @@ # Differential operators Gne = mesh.nodal_gradient # Nodes to edges gradient -mesh.set_cell_gradient_BC(["neumann", "dirichlet", "neumann"]) # Set boundary conditions +mesh.set_cell_gradient_BC( + ["neumann", "dirichlet", "neumann"] +) # Set boundary conditions Gcf = mesh.cell_gradient # Cells to faces gradient D = mesh.face_divergence # Faces to centers divergence Cef = mesh.edge_curl # Edges to faces curl @@ -157,7 +159,9 @@ Mc = sdiag(mesh.cell_volumes * sig) # Inner product matrix (centers) # Differential operators -mesh.set_cell_gradient_BC(["neumann", "dirichlet", "neumann"]) # Set boundary conditions +mesh.set_cell_gradient_BC( + ["neumann", "dirichlet", "neumann"] +) # Set boundary conditions Gcf = mesh.cell_gradient # Cells to faces gradient Dfc = mesh.face_divergence # Faces to centers divergence From ebedd192aac4e66fa4a22e4420cc9b658416a36c Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Fri, 27 Jan 2023 19:31:19 -0800 Subject: [PATCH 11/16] omf deprecations --- discretize/mixins/omf_mod.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/discretize/mixins/omf_mod.py b/discretize/mixins/omf_mod.py index 8da3b54cf..198f70b7b 100644 --- a/discretize/mixins/omf_mod.py +++ b/discretize/mixins/omf_mod.py @@ -209,14 +209,15 @@ def _tensor_mesh_to_omf(mesh, models=None): else: raise RuntimeError("This mesh is too high-dimensional for OMF") # Set rotation axes - geometry.axis_u = mesh.axis_u - geometry.axis_v = mesh.axis_v - geometry.axis_w = mesh.axis_w + orientation = mesh.orientation + geometry.axis_u = orientation[0] + geometry.axis_v = orientation[1] + geometry.axis_w = orientation[2] # Set the origin geometry.origin = mesh.origin # Make sure the geometry is built correctly geometry.validate() - # Make the volume elemet (the OMF object) + # Make the volume element (the OMF object) omfmesh = omf().VolumeElement( geometry=geometry, ) @@ -281,11 +282,14 @@ def _omf_volume_to_tensor(element): """Convert an :class:`omf.VolumeElement` to :class:`discretize.TensorMesh`.""" geometry = element.geometry h = [geometry.tensor_u, geometry.tensor_v, geometry.tensor_w] - mesh = discretize.TensorMesh(h) - mesh.axis_u = geometry.axis_u - mesh.axis_v = geometry.axis_v - mesh.axis_w = geometry.axis_w - mesh.origin = geometry.origin + orientation = np.array( + [ + geometry.axis_u, + geometry.axis_v, + geometry.axis_w, + ] + ) + mesh = discretize.TensorMesh(h, origin=geometry.origin, orientation=orientation) data_dict = {} for data in element.data: From 083e71dc341db9382be6ad4e0ba9b45bd9e77858 Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Mon, 30 Jan 2023 17:14:54 -0800 Subject: [PATCH 12/16] Remove axis_* properties and references. --- discretize/base/base_regular_mesh.py | 5 ----- tests/base/test_tensor_omf.py | 12 ++++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/discretize/base/base_regular_mesh.py b/discretize/base/base_regular_mesh.py index 278fb1bfc..b4e174a39 100644 --- a/discretize/base/base_regular_mesh.py +++ b/discretize/base/base_regular_mesh.py @@ -55,11 +55,6 @@ def __init__( shape_cells = kwargs.pop("n") if "x0" in kwargs: origin = kwargs.pop("x0") - axis_u = kwargs.pop("axis_u", None) - axis_v = kwargs.pop("axis_v", None) - axis_w = kwargs.pop("axis_w", None) - if axis_u is not None and axis_v is not None and axis_w is not None: - orientation = np.array([axis_u, axis_v, axis_w]) shape_cells = tuple((int(val) for val in shape_cells)) self._shape_cells = shape_cells diff --git a/tests/base/test_tensor_omf.py b/tests/base/test_tensor_omf.py index 74a099e21..467cff20d 100644 --- a/tests/base/test_tensor_omf.py +++ b/tests/base/test_tensor_omf.py @@ -33,9 +33,9 @@ def test_to_omf(self): self.assertTrue(np.allclose(mesh.h[0], geom.tensor_u)) self.assertTrue(np.allclose(mesh.h[1], geom.tensor_v)) self.assertTrue(np.allclose(mesh.h[2], geom.tensor_w)) - self.assertTrue(np.allclose(mesh.axis_u, geom.axis_u)) - self.assertTrue(np.allclose(mesh.axis_v, geom.axis_v)) - self.assertTrue(np.allclose(mesh.axis_w, geom.axis_w)) + self.assertTrue(np.allclose(mesh.orientation[0], geom.axis_u)) + self.assertTrue(np.allclose(mesh.orientation[1], geom.axis_v)) + self.assertTrue(np.allclose(mesh.orientation[2], geom.axis_w)) self.assertTrue(np.allclose(mesh.x0, geom.origin)) # Check data arrays @@ -80,9 +80,9 @@ def test_from_omf(self): self.assertTrue(np.allclose(mesh.h[0], geom.tensor_u)) self.assertTrue(np.allclose(mesh.h[1], geom.tensor_v)) self.assertTrue(np.allclose(mesh.h[2], geom.tensor_w)) - self.assertTrue(np.allclose(mesh.axis_u, geom.axis_u)) - self.assertTrue(np.allclose(mesh.axis_v, geom.axis_v)) - self.assertTrue(np.allclose(mesh.axis_w, geom.axis_w)) + self.assertTrue(np.allclose(mesh.orientation[0], geom.axis_u)) + self.assertTrue(np.allclose(mesh.orientation[1], geom.axis_v)) + self.assertTrue(np.allclose(mesh.orientation[2], geom.axis_w)) self.assertTrue(np.allclose(mesh.x0, geom.origin)) # Check data arrays From d8e7c05f40ca0cdb168bec83e1618e60617fbebe Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Thu, 13 Apr 2023 14:29:37 -0700 Subject: [PATCH 13/16] update the test tests --- tests/base/test_tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/base/test_tests.py b/tests/base/test_tests.py index d3c5fd14b..99b63c7c8 100644 --- a/tests/base/test_tests.py +++ b/tests/base/test_tests.py @@ -4,7 +4,7 @@ import subprocess import numpy as np import scipy.sparse as sp -from discretize.tests import assert_isadjoint, checkDerivative, assert_expected_order +from discretize.tests import assert_isadjoint, check_derivative, assert_expected_order class TestAssertIsAdjoint: @@ -73,20 +73,20 @@ def test_simplePass(self): def simplePass(x): return np.sin(x), sp.diags(np.cos(x)) - checkDerivative(simplePass, np.random.randn(5), plotIt=False) + check_derivative(simplePass, np.random.randn(5), plotIt=False) def test_simpleFunction(self): def simpleFunction(x): return np.sin(x), lambda xi: np.cos(x) * xi - checkDerivative(simpleFunction, np.random.randn(5), plotIt=False) + check_derivative(simpleFunction, np.random.randn(5), plotIt=False) def test_simpleFail(self): def simpleFail(x): return np.sin(x), -sp.diags(np.cos(x)) with pytest.raises(AssertionError): - checkDerivative(simpleFail, np.random.randn(5), plotIt=False) + check_derivative(simpleFail, np.random.randn(5), plotIt=False) @pytest.mark.parametrize("test_type", ["mean", "min", "last", "all", "mean_at_least"]) From ea61efea33d29a4eb09bf2504dc26565228d3dd3 Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Mon, 17 Jul 2023 14:28:00 -0700 Subject: [PATCH 14/16] Add 1.0.0 alpha to tested CI --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2f961e10d..d4b12a477 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,6 +2,7 @@ trigger: branches: include: - 'main' + - '1.0.0_alpha' exclude: - '*no-ci*' tags: From f8f336ffcde667cb725de55d240bbd73b2f27d7d Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Tue, 18 Jul 2023 09:13:29 -0700 Subject: [PATCH 15/16] remove branch test (will still run PR test) --- azure-pipelines.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d4b12a477..2f961e10d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -2,7 +2,6 @@ trigger: branches: include: - 'main' - - '1.0.0_alpha' exclude: - '*no-ci*' tags: From 01fd7e1c3aa681ed044000518dee26506d3f3e68 Mon Sep 17 00:00:00 2001 From: Joseph Capriotti Date: Mon, 6 Nov 2023 13:19:16 -0700 Subject: [PATCH 16/16] remove references to removed scripts --- discretize/Tests/meson.build | 9 --------- discretize/meson.build | 2 -- discretize/utils/meson.build | 6 ------ 3 files changed, 17 deletions(-) delete mode 100644 discretize/Tests/meson.build diff --git a/discretize/Tests/meson.build b/discretize/Tests/meson.build deleted file mode 100644 index dac9b559a..000000000 --- a/discretize/Tests/meson.build +++ /dev/null @@ -1,9 +0,0 @@ - -python_sources = [ - '__init__.py', -] - -py.install_sources( - python_sources, - subdir: 'discretize/Tests' -) diff --git a/discretize/meson.build b/discretize/meson.build index 8fb7aa2d9..41b228aca 100644 --- a/discretize/meson.build +++ b/discretize/meson.build @@ -8,7 +8,6 @@ python_sources = [ 'tests.py', 'tree_mesh.py', 'unstructured_mesh.py', - 'View.py', ] py.install_sources( @@ -21,4 +20,3 @@ subdir('_extensions') subdir('mixins') subdir('operators') subdir('utils') -subdir('Tests') diff --git a/discretize/utils/meson.build b/discretize/utils/meson.build index 4bceaff47..136438d06 100644 --- a/discretize/utils/meson.build +++ b/discretize/utils/meson.build @@ -8,12 +8,6 @@ python_sources = [ 'io_utils.py', 'matrix_utils.py', 'mesh_utils.py', - 'codeutils.py', - 'coordutils.py', - 'curvutils.py', - 'interputils.py', - 'matutils.py', - 'meshutils.py', ] py.install_sources(