How to use the meshplex.base._base_mesh function in meshplex

To help you get started, we’ve selected a few meshplex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / meshplex / meshplex / mesh_tetra.py View on Github external
import numpy

from .base import _base_mesh, compute_tri_areas, compute_triangle_circumcenters

__all__ = ["MeshTetra"]


# pylint: disable=too-many-instance-attributes
class MeshTetra(_base_mesh):
    """Class for handling tetrahedral meshes.
    """

    def __init__(self, node_coords, cells):
        """Initialization.
        """
        # Sort cells and nodes, first every row, then the rows themselves. This helps in
        # many downstream applications, e.g., when constructing linear systems with the
        # cells/edges. (When converting to CSR format, the I/J entries must be sorted.)
        # Don't use cells.sort(axis=1) to avoid
        # ```
        # ValueError: sort array is read-only
        # ```
        cells = numpy.sort(cells, axis=1)
        cells = cells[cells[:, 0].argsort()]
github nschloe / meshplex / meshplex / mesh_tri.py View on Github external
import os

import numpy

from .base import (
    _base_mesh,
    compute_ce_ratios,
    compute_tri_areas,
    compute_triangle_circumcenters,
)
from .helpers import grp_start_len, unique_rows

__all__ = ["MeshTri"]


class MeshTri(_base_mesh):
    """Class for handling triangular meshes.
    """

    def __init__(self, nodes, cells, sort_cells=False):
        """Initialization.
        """
        if sort_cells:
            # Sort cells and nodes, first every row, then the rows themselves. This
            # helps in many downstream applications, e.g., when constructing linear
            # systems with the cells/edges. (When converting to CSR format, the I/J
            # entries must be sorted.) Don't use cells.sort(axis=1) to avoid
            # ```
            # ValueError: sort array is read-only
            # ```
            cells = numpy.sort(cells, axis=1)
            cells = cells[cells[:, 0].argsort()]