Showing preview only (2,286K chars total). Download the full file or copy to clipboard to get everything.
Repository: simpeg/discretize
Branch: main
Commit: c7763885314e
Files: 214
Total size: 2.1 MB
Directory structure:
gitextract_xzf28t4b/
├── .ci/
│ ├── azure/
│ │ ├── deploy.yml
│ │ ├── docs.yml
│ │ ├── run_tests.sh
│ │ ├── sdist.yml
│ │ ├── setup_env.sh
│ │ ├── setup_miniconda_macos.sh
│ │ ├── style.yml
│ │ └── test.yml
│ ├── environment_test.yml
│ ├── environment_test_bare.yml
│ ├── install_style.sh
│ ├── parse_style_requirements.py
│ └── setup_headless_display.sh
├── .git_archival.txt
├── .gitattributes
├── .github/
│ └── workflows/
│ └── build_distributions.yml
├── .gitignore
├── .pre-commit-config.yaml
├── AUTHORS.rst
├── CITATION.rst
├── LICENSE
├── README.rst
├── azure-pipelines.yml
├── discretize/
│ ├── Tests/
│ │ ├── __init__.py
│ │ └── meson.build
│ ├── View.py
│ ├── __init__.py
│ ├── _extensions/
│ │ ├── __init__.py
│ │ ├── geom.cpp
│ │ ├── geom.h
│ │ ├── geom.pxd
│ │ ├── interputils_cython.pxd
│ │ ├── interputils_cython.pyx
│ │ ├── meson.build
│ │ ├── simplex_helpers.pyx
│ │ ├── tree.cpp
│ │ ├── tree.h
│ │ ├── tree.pxd
│ │ ├── tree_ext.pyx
│ │ └── triplet.h
│ ├── base/
│ │ ├── __init__.py
│ │ ├── base_mesh.py
│ │ ├── base_regular_mesh.py
│ │ ├── base_tensor_mesh.py
│ │ └── meson.build
│ ├── curvilinear_mesh.py
│ ├── cylindrical_mesh.py
│ ├── meson.build
│ ├── mixins/
│ │ ├── __init__.py
│ │ ├── mesh_io.py
│ │ ├── meson.build
│ │ ├── mpl_mod.py
│ │ ├── omf_mod.py
│ │ └── vtk_mod.py
│ ├── operators/
│ │ ├── __init__.py
│ │ ├── differential_operators.py
│ │ ├── inner_products.py
│ │ └── meson.build
│ ├── tensor_cell.py
│ ├── tensor_mesh.py
│ ├── tests.py
│ ├── tree_mesh.py
│ ├── unstructured_mesh.py
│ └── utils/
│ ├── __init__.py
│ ├── code_utils.py
│ ├── codeutils.py
│ ├── coordinate_utils.py
│ ├── coordutils.py
│ ├── curvilinear_utils.py
│ ├── curvutils.py
│ ├── interpolation_utils.py
│ ├── interputils.py
│ ├── io_utils.py
│ ├── matrix_utils.py
│ ├── matutils.py
│ ├── mesh_utils.py
│ ├── meshutils.py
│ └── meson.build
├── docs/
│ ├── Makefile
│ ├── _static/
│ │ ├── css/
│ │ │ └── custom.css
│ │ └── versions.json
│ ├── _templates/
│ │ └── autosummary/
│ │ ├── attribute.rst
│ │ ├── base.rst
│ │ ├── class.rst
│ │ ├── function.rst
│ │ └── method.rst
│ ├── api/
│ │ ├── discretize.base.rst
│ │ ├── discretize.mixins.rst
│ │ ├── discretize.operators.rst
│ │ ├── discretize.rst
│ │ ├── discretize.tests.rst
│ │ ├── discretize.utils.rst
│ │ └── index.rst
│ ├── conf.py
│ ├── content/
│ │ ├── additional_resources.rst
│ │ ├── big_picture.rst
│ │ ├── finite_volume.rst
│ │ ├── getting_started.rst
│ │ ├── inner_products.rst
│ │ ├── installing.rst
│ │ ├── theory.rst
│ │ └── user_guide.rst
│ ├── index.rst
│ ├── make.bat
│ └── release/
│ ├── 0.10.0-notes.rst
│ ├── 0.11.0-notes.rst
│ ├── 0.11.1-notes.rst
│ ├── 0.11.2-notes.rst
│ ├── 0.11.3-notes.rst
│ ├── 0.12.0-notes.rst
│ ├── 0.4.12-notes.rst
│ ├── 0.4.13-notes.rst
│ ├── 0.4.14-notes.rst
│ ├── 0.4.15-notes.rst
│ ├── 0.5.0-notes.rst
│ ├── 0.5.1-notes.rst
│ ├── 0.6.0-notes.rst
│ ├── 0.6.1-notes.rst
│ ├── 0.6.2-notes.rst
│ ├── 0.6.3-notes.rst
│ ├── 0.7.0-notes.rst
│ ├── 0.7.1-notes.rst
│ ├── 0.7.2-notes.rst
│ ├── 0.7.3-notes.rst
│ ├── 0.7.4-notes.rst
│ ├── 0.8.0-notes.rst
│ ├── 0.8.1-notes.rst
│ ├── 0.8.2-notes.rst
│ ├── 0.8.3-notes.rst
│ ├── 0.9.0-notes.rst
│ └── index.rst
├── examples/
│ ├── README.txt
│ ├── plot_cahn_hilliard.py
│ ├── plot_cyl_mirror.py
│ ├── plot_dc_resistivity.py
│ ├── plot_image.py
│ ├── plot_pyvista_laguna.py
│ ├── plot_quadtree_divergence.py
│ ├── plot_quadtree_hanging.py
│ ├── plot_slicer_demo.py
│ └── plot_streamThickness.py
├── meson.build
├── meson.options
├── pyproject.toml
├── tests/
│ ├── __init__.py
│ ├── base/
│ │ ├── __init__.py
│ │ ├── test_basemesh.py
│ │ ├── test_coordutils.py
│ │ ├── test_curvilinear.py
│ │ ├── test_curvilinear_vtk.py
│ │ ├── test_interpolation.py
│ │ ├── test_operators.py
│ │ ├── test_properties.py
│ │ ├── test_slicer.py
│ │ ├── test_tensor.py
│ │ ├── test_tensor_cell.py
│ │ ├── test_tensor_innerproduct.py
│ │ ├── test_tensor_innerproduct_derivs.py
│ │ ├── test_tensor_io.py
│ │ ├── test_tensor_omf.py
│ │ ├── test_tensor_vtk.py
│ │ ├── test_tests.py
│ │ ├── test_utils.py
│ │ ├── test_view.py
│ │ └── test_volume_avg.py
│ ├── boundaries/
│ │ ├── test_boundary_integrals.py
│ │ ├── test_boundary_maxwell.py
│ │ ├── test_boundary_poisson.py
│ │ ├── test_errors.py
│ │ ├── test_tensor_boundary.py
│ │ └── test_tensor_boundary_poisson.py
│ ├── cyl/
│ │ ├── __init__.py
│ │ ├── test_cyl.py
│ │ ├── test_cyl3D.py
│ │ ├── test_cylOperators.py
│ │ ├── test_cyl_counting.py
│ │ ├── test_cyl_innerproducts.py
│ │ ├── test_cyl_io.py
│ │ └── test_cyl_operators.py
│ ├── simplex/
│ │ ├── __init__.py
│ │ ├── test_inner_products.py
│ │ ├── test_interpolation.py
│ │ ├── test_operators.py
│ │ └── test_utils.py
│ └── tree/
│ ├── __init__.py
│ ├── test_intersections.py
│ ├── test_refine.py
│ ├── test_safeguards.py
│ ├── test_tree.py
│ ├── test_tree_balancing.py
│ ├── test_tree_innerproduct_derivs.py
│ ├── test_tree_interpolation.py
│ ├── test_tree_io.py
│ ├── test_tree_operators.py
│ ├── test_tree_plotting.py
│ ├── test_tree_utils.py
│ └── test_tree_vtk.py
└── tutorials/
├── inner_products/
│ ├── 1_basic.py
│ ├── 2_physical_properties.py
│ ├── 3_calculus.py
│ ├── 4_advanced.py
│ └── README.txt
├── mesh_generation/
│ ├── 1_mesh_overview.py
│ ├── 2_tensor_mesh.py
│ ├── 3_cylindrical_mesh.py
│ ├── 4_tree_mesh.py
│ └── README.txt
├── operators/
│ ├── 1_averaging.py
│ ├── 2_differential.py
│ └── README.txt
└── pde/
├── 1_poisson.py
├── 2_advection_diffusion.py
├── 3_nodal_dirichlet_poisson.py
└── README.txt
================================================
FILE CONTENTS
================================================
================================================
FILE: .ci/azure/deploy.yml
================================================
jobs:
- job:
displayName: "Deploy Docs"
pool:
vmImage: ubuntu-latest
steps:
# No need to checkout the repo here!
- checkout: none
- bash: |
echo $IS_TAG
echo $IS_MAIN
echo $BRANCH_NAME
displayName: Report branch parameters
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'html_docs'
targetPath: 'html'
- bash: |
ls -l html
displayName: Report downloaded cache contents.
- bash: |
git config --global user.name ${GH_NAME}
git config --global user.email ${GH_EMAIL}
git config --list | grep user.
displayName: 'Configure git'
env:
GH_NAME: $(gh.name)
GH_EMAIL: $(gh.email)
# upload documentation to discretize-docs gh-pages on tags
- bash: |
git clone -q --branch gh-pages --depth 1 https://${GH_TOKEN}@github.com/simpeg/discretize-docs.git
displayName: Checkout doc repository
env:
GH_TOKEN: $(gh.token)
- bash: |
cd discretize-docs
rm -rf "en/$BRANCH_NAME"
mv ../html "en/$BRANCH_NAME"
touch .nojekyll
displayName: Set Doc Folder
- bash: |
# Update latest symlink
cd discretize-docs/en
rm -f latest
ln -s "$BRANCH_NAME" latest
displayName: Point Latest to tag
condition: eq(variables.IS_TAG, true)
- bash: |
# Commit and push
cd discretize-docs
git add --all
git commit -am "Azure CI commit ref $(Build.SourceVersion)"
git push
displayName: Push documentation to discretize-docs
env:
GH_TOKEN: $(gh.token)
================================================
FILE: .ci/azure/docs.yml
================================================
jobs:
- job: BuildDocs
displayName: "Build Documentation"
pool:
vmImage: ubuntu-latest
variables:
python.version: "3.11"
doc.build: True
PYVISTA_OFF_SCREEN: True
DISPLAY: ":99"
steps:
- bash:
git fetch --tags
displayName: Fetch tags
- bash: echo "##vso[task.prependpath]$CONDA/bin"
displayName: Add conda to PATH
- bash: .ci/azure/setup_env.sh
displayName: Setup discretize environment
- bash: |
source activate discretize-test
make -C docs html
displayName: 'Building HTML'
- bash: |
source activate discretize-test
make -C docs linkcheck
displayName: 'Checking Links'
- task: PublishPipelineArtifact@1
inputs:
targetPath: 'docs/_build/html'
artifact: 'html_docs'
parallel: true
================================================
FILE: .ci/azure/run_tests.sh
================================================
#!/bin/bash
set -ex #echo on and exit if any line fails
# TF_BUILD is set to True on azure pipelines.
is_azure=$(echo "${TF_BUILD:-false}" | tr '[:upper:]' '[:lower:]')
do_doc=$(echo "${DOC_BUILD:-false}" | tr '[:upper:]' '[:lower:]')
do_cov=$(echo "${COVERAGE:-false}" | tr '[:upper:]' '[:lower:]')
test_args=""
source activate discretize-test
if [[ "$is_azure" == "true" ]]; then
if [[ "$do_doc" == "true" ]]; then
.ci/setup_headless_display.sh
fi
fi
if [[ "do_cov" == "true" ]]; then
echo "Testing with coverage"
test_args="--cov --cov-config=pyproject.toml $test_args"
fi
pytest -vv $test_args
if [[ "do_cov" == "true" ]]; then
coverage xml
fi
================================================
FILE: .ci/azure/sdist.yml
================================================
jobs:
- job:
displayName: "Build source dist."
pool:
vmImage: ubuntu-latest
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: "3.11"
- bash:
git fetch --tags
displayName: Fetch tags
- bash: |
set -o errexit
python -m pip install --upgrade pip
pip install build
displayName: Install source build tools.
- bash: |
python -m build --skip-dependency-check --sdist .
ls -la dist
displayName: Build Source
- task: PublishPipelineArtifact@1
inputs:
targetPath: 'dist'
artifact: 'source_dist'
================================================
FILE: .ci/azure/setup_env.sh
================================================
#!/bin/bash
set -ex #echo on and exit if any line fails
# TF_BUILD is set to True on azure pipelines.
is_azure=$(echo "${TF_BUILD:-false}" | tr '[:upper:]' '[:lower:]')
do_doc=$(echo "${DOC_BUILD:-false}" | tr '[:upper:]' '[:lower:]')
is_free_threaded=$(echo "${PYTHON_FREETHREADING:-false}" | tr '[:upper:]' '[:lower:]')
is_rc=$(echo "${PYTHON_RELEASE_CANDIDATE:-false}" | tr '[:upper:]' '[:lower:]')
is_bare=$(echo "${ENVIRON_BARE:-false}" | tr '[:upper:]' '[:lower:]')
if [[ "$is_azure" == "true" ]]; then
if [[ "$do_doc" == "true" ]]; then
.ci/setup_headless_display.sh
fi
fi
if [[ "$is_free_threaded" == "true" || "$is_bare" == "true" ]]; then
cp .ci/environment_test_bare.yml environment_test_with_pyversion.yml
echo " - python-freethreading="$PYTHON_VERSION >> environment_test_with_pyversion.yml
else
cp .ci/environment_test.yml environment_test_with_pyversion.yml
echo " - python="$PYTHON_VERSION >> environment_test_with_pyversion.yml
fi
if [[ "$is_rc" == "true" ]]; then
sed -i '/^channels:/a\ - conda-forge/label/python_rc' environment_test_with_pyversion.yml
fi
conda env create --file environment_test_with_pyversion.yml
rm environment_test_with_pyversion.yml
if [[ "$is_azure" == "true" ]]; then
source activate discretize-test
pip install pytest-azurepipelines
else
conda activate discretize-test
fi
# The --vsenv config setting will prefer msvc compilers on windows.
# but will do nothing on mac and linux.
pip install --no-build-isolation --editable . --config-settings=setup-args="--vsenv"
echo "Conda Environment:"
conda list
echo "Installed discretize version:"
python -c "import discretize; print(discretize.__version__)"
================================================
FILE: .ci/azure/setup_miniconda_macos.sh
================================================
#!/bin/bash
set -ex #echo on and exit if any line fails
echo "arch is $ARCH"
if [[ $ARCH == "X64" ]]; then
MINICONDA_ARCH_LABEL="x86_64"
else
MINICONDA_ARCH_LABEL="arm64"
fi
echo $MINICONDA_ARCH_LABEL
mkdir -p ~/miniconda3
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-$MINICONDA_ARCH_LABEL.sh -o ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh
echo "##vso[task.setvariable variable=CONDA;]${HOME}/miniconda3"
================================================
FILE: .ci/azure/style.yml
================================================
jobs:
- job:
displayName: Run style checks with Black
pool:
vmImage: ubuntu-latest
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: "3.11"
- bash: .ci/install_style.sh
displayName: "Install dependencies to run the checks"
- script: black --check .
displayName: "Run black"
- job:
displayName: Run (permissive) style checks with flake8
pool:
vmImage: ubuntu-latest
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: "3.11"
- bash: .ci/install_style.sh
displayName: "Install dependencies to run the checks"
- script: flake8
displayName: "Run flake8"
================================================
FILE: .ci/azure/test.yml
================================================
jobs:
- job:
strategy:
matrix:
linux-Python311:
image: ubuntu-latest
python.version: '3.11'
coverage: True
linux-Python312:
image: ubuntu-latest
python.version: '3.12'
linux-Python313:
image: ubuntu-latest
python.version: '3.13'
linux-Python313t:
image: ubuntu-latest
python.version: '3.13'
environ.bare: True
python.freethreading: True
coverage: True
linux-Python314:
image: ubuntu-latest
environ.bare: True
python.version: '3.14'
linux-Python314t:
image: ubuntu-latest
python.version: '3.14'
environ.bare: True
python.freethreading: True
osx-Python311:
image: macOS-latest
python.version: '3.11'
osx-Python312:
image: macOS-latest
python.version: '3.12'
osx-Python313:
image: macOS-latest
python.version: '3.13'
osx-Python313t:
image: macOS-latest
python.version: '3.13'
python.freethreading: True
osx-Python314:
image: macOS-latest
python.version: '3.14'
environ.bare: True
osx-Python314t:
image: macOS-latest
python.version: '3.14'
environ.bare: True
python.freethreading: True
win-Python311:
image: windows-latest
python.version: '3.11'
win-Python312:
image: windows-latest
python.version: '3.12'
win-Python313:
image: windows-latest
python.version: '3.13'
win-Python313t:
image: windows-latest
python.version: '3.13'
environ.bare: True
python.freethreading: True
win-Python314:
image: windows-latest
environ.bare: True
python.version: '3.14'
win-Python314t:
image: windows-latest
python.version: '3.14'
environ.bare: True
python.freethreading: True
displayName: "${{ variables.image }} ${{ variables.python.version }}"
pool:
vmImage: $(image)
variables:
varOS: $(Agent.OS)
ARCH: $(Agent.OSArchitecture)
steps:
- bash: .ci/azure/setup_miniconda_macos.sh
displayName: Install miniconda on mac
condition: eq(variables.varOS, 'Darwin')
- bash: echo "##vso[task.prependpath]$CONDA/bin"
displayName: Add conda to PATH
condition: ne(variables.varOS, 'Windows_NT')
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
displayName: Add conda to PATH
condition: eq(variables.varOS, 'Windows_NT')
- bash: .ci/azure/setup_env.sh
displayName: Setup discretize environment
- bash: .ci/azure/run_tests.sh
displayName: 'Testing'
- bash: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov
displayName: 'Upload coverage to codecov.io'
condition: variables.coverage
================================================
FILE: .ci/environment_test.yml
================================================
name: discretize-test
channels:
- conda-forge
dependencies:
- numpy>=1.22.4
- scipy>=1.8
# optionals
- vtk>=6
- pyvista
- omf
- matplotlib
# documentation
- sphinx==8.1.3
- pydata-sphinx-theme==0.16.1
- sphinx-gallery==0.19.0
- numpydoc==1.9.0
- jupyter
- graphviz
- pillow
- pooch
# testing
- sympy
- pytest
- pytest-cov
# Building
- pip
- meson-python>=0.14.0
- meson
- ninja
- cython>=3.1.0
- setuptools_scm
================================================
FILE: .ci/environment_test_bare.yml
================================================
name: discretize-test
channels:
- conda-forge
dependencies:
- numpy>=1.22.4
- scipy>=1.12
# testing
- sympy
- pytest
- pytest-cov
# Building
- pip
- meson-python>=0.14.0
- meson
- ninja
- cython>=3.1.0
- setuptools_scm
================================================
FILE: .ci/install_style.sh
================================================
#!/bin/bash
set -ex #echo on and exit if any line fails
# get directory of this script
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
style_script=$script_dir/parse_style_requirements.py
# parse the style requirements
requirements=$(python $style_script)
pip install $requirements
================================================
FILE: .ci/parse_style_requirements.py
================================================
import tomllib
import pathlib
root_dir = pathlib.Path(__file__).parent.parent.resolve()
pyproject_file = root_dir / "pyproject.toml"
with open(pyproject_file, "rb") as f:
pyproject = tomllib.load(f)
style_requirements = pyproject["project"]["optional-dependencies"]["style"]
for req in style_requirements:
print(req)
================================================
FILE: .ci/setup_headless_display.sh
================================================
#!/bin/sh
set -x
sudo apt update
# Install items for headless pyvista display.
sudo apt-get install -y \
libglx-mesa0 \
libgl1 \
xvfb \
x11-xserver-utils
# qt dependents
sudo apt-get install -y \
libdbus-1-3 \
libegl1 \
libopengl0 \
libosmesa6 \
libxcb-cursor0 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-shape0 \
libxcb-xfixes0 \
libxcb-xinerama0 \
libxcb-xinput0 \
libxkbcommon-x11-0 \
mesa-utils \
x11-utils
which Xvfb
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
# Debugging commands:
# ls -l /etc/init.d/
# sh -e /etc/init.d/xvfb start
# give xvfb some time to start
sleep 3
set +x
================================================
FILE: .git_archival.txt
================================================
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
================================================
FILE: .gitattributes
================================================
.git_archival.txt export-subst
# Excluding files from an sdist generated by meson-python
.azure-pipelines/* export-ignore
.ci/* export-ignore
docs/* export-ignore
examples/* export-ignore
tests/* export-ignore
tutorials/* export-ignore
.coveragerc export-ignore
.flake8 export-ignore
.git* export-ignore
*.yml export-ignore
*.yaml export-ignore
requirements_style.txt export-ignore
================================================
FILE: .github/workflows/build_distributions.yml
================================================
name: Build Distribution artifacts
on: [push, pull_request]
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-15-intel is an Intel runner, macos-14 is Apple silicon
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-15-intel, macos-14]
steps:
- uses: actions/checkout@v5
- name: Build wheels
uses: pypa/cibuildwheel@v3.2.0
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true
packages-dir: ./dist/
================================================
FILE: .gitignore
================================================
*.py[cod]
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
eggs
.eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
__pycache__
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
nosetests.xml
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
*.sublime-project
*.sublime-workspace
.DS_Store
tree_ext.cpp
simplex_helpers.cpp
interputils_cython.c
# Jupyter
*.ipynb
# docs
docs/_build/
docs/warnings.txt
docs/api/generated/*
docs/examples
docs/gallery/*
docs/tutorials/*
# Examples data
/examples/Chile_GRAV_4_Miller
/examples/*.tar.gz
examples/Chile_GRAV_4_Miller
examples/*.tar.gz
# downloads for examples
*.tar.gz
*.dat
*.dir
*.bak
# setuptools_scm
discretize/version.py
.idea/
docs/sg_execution_times.rst
================================================
FILE: .pre-commit-config.yaml
================================================
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.3.0
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
language_version: python3.11
additional_dependencies:
- flake8-bugbear==23.12.2
- flake8-builtins==2.2.0
- flake8-mutable==1.2.0
- flake8-rst-docstrings==0.3.0
- flake8-docstrings==1.7.0
- flake8-pyproject==1.2.3
================================================
FILE: AUTHORS.rst
================================================
- Rowan Cockett, (`@rowanc1 <https://github.com/rowanc1/>`_)
- Lindsey Heagy, (`@lheagy <https://github.com/lheagy/>`_)
- Seogi Kang, (`@sgkang <https://github.com/sgkang/>`_)
- Brendan Smithyman, (`@bsmithyman <https://github.com/bsmithyman/>`_)
- Gudni Rosenkjaer, (`@grosenkj <https://github.com/grosenkj/>`_)
- Dom Fournier, (`@fourndo <https://github.com/fourndo/>`_)
- Dave Marchant, (`@dwfmarchant <https://github.com/dwfmarchant/>`_)
- Lars Ruthotto, (`@lruthotto <https://github.com/lruthotto/>`_)
- Mike Wathen, (`@wathenmp <https://github.com/wathenmp/>`_)
- Luz Angelica Caudillo-Mata, (`@lacmajedrez <https://github.com/lacmajedrez/>`_)
- Eldad Haber, (`@eldadhaber <https://github.com/eldadhaber/>`_)
- Doug Oldenburg, (`@dougoldenburg <https://github.com/dougoldenburg/>`_)
- Devin Cowan, (`@dccowan <https://github.com/dccowan/>`_)
- Adam Pidlisecky, (`@aPid1 <https://github.com/aPid1/>`_)
- Dieter Werthmüller, (`@prisae <https://github.com/prisae/>`_)
- Bane Sullivan, (`@banesullivan <https://github.com/banesullivan>`_)
- Joseph Capriotti, (`@jcapriot <https://github.com/jcapriot/>`_)
================================================
FILE: CITATION.rst
================================================
Citing discretize
-----------------
There is a `paper about discretize <http://dx.doi.org/10.1016/j.cageo.2015.09.015>`_ as it is used in SimPEG,
if you use this code, please help our scientific visibility by citing our work!
Cockett, R., Kang, S., Heagy, L. J., Pidlisecky, A., & Oldenburg, D. W. (2015). SimPEG: An open source framework for simulation and gradient based parameter estimation in geophysical applications. Computers & Geosciences.
BibTex:
.. code:: Latex
@article{Cockett2015,
title={SimPEG: An open source framework for simulation and gradient based parameter estimation in geophysical applications},
author={Cockett, Rowan and Kang, Seogi and Heagy, Lindsey J and Pidlisecky, Adam and Oldenburg, Douglas W},
journal={Computers \& Geosciences},
year={2015},
publisher={Elsevier}
}
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2013-2025 SimPEG Developers
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: README.rst
================================================
.. image:: https://raw.github.com/simpeg/discretize/main/docs/images/discretize-logo.png
:alt: Discretize Logo
discretize
==========
.. image:: https://img.shields.io/pypi/v/discretize.svg
:target: https://pypi.python.org/pypi/discretize
:alt: Latest PyPI version
.. image:: https://anaconda.org/conda-forge/discretize/badges/version.svg
:target: https://anaconda.org/conda-forge/discretize
:alt: Latest conda-forge version
.. image:: https://img.shields.io/github/license/simpeg/simpeg.svg
:target: https://github.com/simpeg/discretize/blob/main/LICENSE
:alt: MIT license
.. image:: https://dev.azure.com/simpeg/discretize/_apis/build/status/simpeg.discretize?branchName=main
:target: https://dev.azure.com/simpeg/discretize/_build/latest?definitionId=1&branchName=main
:alt: Azure pipelines build status
.. image:: https://codecov.io/gh/simpeg/discretize/branch/main/graph/badge.svg
:target: https://codecov.io/gh/simpeg/discretize
:alt: Coverage status
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.596411.svg
:target: https://doi.org/10.5281/zenodo.596411
.. image:: https://img.shields.io/discourse/users?server=http%3A%2F%2Fsimpeg.discourse.group%2F
:target: http://simpeg.discourse.group/
.. image:: https://img.shields.io/badge/simpeg-purple?logo=mattermost&label=Mattermost
:target: https://mattermost.softwareunderground.org/simpeg
.. image:: https://img.shields.io/badge/Youtube%20channel-GeoSci.xyz-FF0000.svg?logo=youtube
:target: https://www.youtube.com/channel/UCBrC4M8_S4GXhyHht7FyQqw
**discretize** - A python package for finite volume discretization.
The vision is to create a package for finite volume simulation with a
focus on large scale inverse problems.
This package has the following features:
* modular with respect to the spacial discretization
* built with the inverse problem in mind
* supports 1D, 2D and 3D problems
* access to sparse matrix operators
* access to derivatives to mesh variables
.. image:: https://raw.githubusercontent.com/simpeg/figures/master/finitevolume/cell-anatomy-tensor.png
Currently, discretize supports:
* Tensor Meshes (1D, 2D and 3D)
* Cylindrically Symmetric Meshes
* QuadTree and OcTree Meshes (2D and 3D)
* Logically Rectangular Meshes (2D and 3D)
* Triangular (2D) and Tetrahedral (3D) Meshes
Installing
^^^^^^^^^^
**discretize** is on conda-forge, and is the recommended installation method.
.. code:: shell
conda install -c conda-forge discretize
Prebuilt wheels of **discretize** are on pypi for most platforms
.. code:: shell
pip install discretize
To install from source, note this requires a `c++` compiler supporting the `c++17` standard.
.. code:: shell
git clone https://github.com/simpeg/discretize.git
cd discretize
pip install .
Citing discretize
^^^^^^^^^^^^^^^^^
Please cite the SimPEG paper when using discretize in your work:
Cockett, R., Kang, S., Heagy, L. J., Pidlisecky, A., & Oldenburg, D. W. (2015). SimPEG: An open source framework for simulation and gradient based parameter estimation in geophysical applications. Computers & Geosciences.
**BibTex:**
.. code:: Latex
@article{cockett2015simpeg,
title={SimPEG: An open source framework for simulation and gradient based parameter estimation in geophysical applications},
author={Cockett, Rowan and Kang, Seogi and Heagy, Lindsey J and Pidlisecky, Adam and Oldenburg, Douglas W},
journal={Computers \& Geosciences},
year={2015},
publisher={Elsevier}
}
Links
^^^^^
Website:
http://simpeg.xyz
Documentation:
http://discretize.simpeg.xyz
Code:
https://github.com/simpeg/discretize
Tests:
https://dev.azure.com/simpeg/discretize/_build
Bugs & Issues:
https://github.com/simpeg/discretize/issues
Questions:
http://simpeg.discourse.group/
Chat:
https://mattermost.softwareunderground.org/simpeg
================================================
FILE: azure-pipelines.yml
================================================
trigger:
branches:
include:
- 'main'
exclude:
- '*no-ci*'
tags:
include:
- '*'
pr:
branches:
include:
- '*'
exclude:
- '*no-ci*'
variables:
BRANCH_NAME: $(Build.SourceBranchName)
IS_TAG: $[startsWith(variables['Build.SourceBranch'], 'refs/tags/')]
IS_MAIN: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]
stages:
- stage: StyleChecks
displayName: "Style Checks"
jobs:
- template: .ci/azure/style.yml
- stage: Testing
dependsOn: StyleChecks
jobs:
- template: .ci/azure/test.yml
- stage: DocBuild
dependsOn: StyleChecks
jobs:
- template: .ci/azure/docs.yml
- stage: Deploy
displayName: "Deploy Docs"
dependsOn:
- Testing
- DocBuild
condition: and(succeeded(), or(eq(variables.IS_TAG, true), eq(variables.IS_MAIN, true)))
jobs:
- template: .ci/azure/deploy.yml
================================================
FILE: discretize/Tests/__init__.py
================================================
from discretize.tests import * # NOQA F401,F403
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", error=True
)
================================================
FILE: discretize/Tests/meson.build
================================================
python_sources = [
'__init__.py',
]
py.install_sources(
python_sources,
subdir: 'discretize/Tests'
)
================================================
FILE: discretize/View.py
================================================
"""Deprecated view module."""
from discretize.utils.code_utils import deprecate_module
deprecate_module(
"discretize.View",
"discretize.mixins.mpl_mod",
removal_version="1.0.0",
error=True,
)
try:
from discretize.mixins.mpl_mod import Slicer # NOQA F401
except ImportError:
pass
================================================
FILE: discretize/__init__.py
================================================
"""
=====================================
Discretize Meshes (:mod:`discretize`)
=====================================
.. currentmodule:: discretize
The ``discretize`` package contains four types of meshes for soliving partial differential
equations using the finite volume method.
Mesh Classes
============
.. autosummary::
:toctree: generated/
TensorMesh
CylindricalMesh
CurvilinearMesh
TreeMesh
SimplexMesh
Mesh Cells
==========
The :class:`~discretize.tensor_cell.TensorCell` and
:class:`~discretize.tree_mesh.TreeCell` classes were designed specifically to
define the cells within tensor and tree meshes, respectively.
Instances of :class:`~discretize.tree_mesh.TreeCell` and
:class:`~discretize.tensor_cell.TensorCell` are not meant to be created on
their own.
However, they can be returned directly by indexing a particular cell within
a tensor or tree mesh.
.. autosummary::
:toctree: generated/
tensor_cell.TensorCell
tree_mesh.TreeCell
"""
from discretize.tensor_mesh import TensorMesh
from discretize.cylindrical_mesh import CylMesh, CylindricalMesh
from discretize.curvilinear_mesh import CurvilinearMesh
from discretize.unstructured_mesh import SimplexMesh
from discretize.utils.io_utils import load_mesh
from .tensor_cell import TensorCell
try:
from discretize.tree_mesh import TreeMesh
except ImportError as err:
import os
# Check if being called from non-standard location (i.e. a git repository)
# is tree_ext.pyx here? will not be in the folder if installed to site-packages...
file_test = os.path.dirname(os.path.abspath(__file__)) + "/_extensions/tree_ext.pyx"
if os.path.isfile(file_test):
# Then we are being run from a repository
raise ImportError(
"""
It would appear that discretize is being imported from its source code
directory and is unable to load its compiled extension modules. Try changing
your directory and re-launching your python interpreter.
If this was intentional, you need to install discretize in an editable mode.
"""
)
else:
raise err
from discretize import tests
__author__ = "SimPEG Team"
__license__ = "MIT"
__copyright__ = "2013 - 2023, SimPEG Developers, https://simpeg.xyz"
from importlib.metadata import version, PackageNotFoundError
# Version
try:
# - Released versions just tags: 0.8.0
# - GitHub commits add .dev#+hash: 0.8.1.dev4+g2785721
# - Uncommitted changes add timestamp: 0.8.1.dev4+g2785721.d20191022
__version__ = version("discretize")
except PackageNotFoundError:
# If it was not installed, then we don't know the version. We could throw a
# warning here, but this case *should* be rare. discretize should be
# installed properly!
from datetime import datetime
__version__ = "unknown-" + datetime.today().strftime("%Y%m%d")
================================================
FILE: discretize/_extensions/__init__.py
================================================
================================================
FILE: discretize/_extensions/geom.cpp
================================================
#include <algorithm>
#include <limits>
#include "geom.h"
#include <algorithm>
#include <limits>
// Define the 3D cross product as a pre-processor macro
#define CROSS3D(e0, e1, out) \
out[0] = e0[1] * e1[2] - e0[2] * e1[1]; \
out[1] = e0[2] * e1[0] - e0[0] * e1[2]; \
out[2] = e0[0] * e1[1] - e0[1] * e1[0];
// simple geometric objects for intersection tests with an aabb
Geometric::Geometric(){
dim = 0;
}
Geometric::Geometric(int_t dim){
this->dim = dim;
}
Ball::Ball() : Geometric(){
x0 = NULL;
r = 0;
rsq = 0;
}
Ball::Ball(int_t dim, double* x0, double r) : Geometric(dim){
this->x0 = x0;
this->r = r;
this->rsq = r * r;
}
bool Ball::intersects_cell(double *a, double *b) const{
// check if I intersect the ball
double dx;
double r2_test = 0.0;
for(int_t i=0; i<dim; ++i){
dx = std::max(a[i], std::min(x0[i], b[i])) - x0[i];
r2_test += dx * dx;
}
return r2_test < rsq;
}
Line::Line() : Geometric(){
x0 = NULL;
x1 = NULL;
for(int_t i=0; i<3; ++i) inv_dx[i] = 1;
}
Line::Line(int_t dim, double* x0, double *x1) : Geometric(dim){
this->x0 = x0;
this->x1 = x1;
for(int_t i=0; i<dim; ++i){
inv_dx[i] = 1.0/(x1[i] - x0[i]);
}
}
bool Line::intersects_cell(double *a, double *b) const{
double t_near = -std::numeric_limits<double>::infinity();
double t_far = std::numeric_limits<double>::infinity();
double t0, t1;
for(int_t i=0; i<dim; ++i){
// do a quick test if the line has no chance of intersecting the aabb
if(x0[i] == x1[i] && (x0[i] < a[i] || x0[i] > b[i])){
return false;
}
if(std::max(x0[i], x1[i]) < a[i]){
return false;
}
if(std::min(x0[i], x1[i]) > b[i]){
return false;
}
if (x0[i] != x1[i]){
t0 = (a[i] - x0[i]) * inv_dx[i];
t1 = (b[i] - x0[i]) * inv_dx[i];
if (t0 > t1){
std::swap(t0, t1);
}
t_near = std::max(t_near, t0);
t_far = std::min(t_far, t1);
if (t_near > t_far || t_far < 0 || t_near > 1){
return false;
}
}
}
return true;
}
Box::Box() : Geometric(){
x0 = NULL;
x1 = NULL;
}
Box::Box(int_t dim, double* x0, double *x1) : Geometric(dim){
this->x0 = x0;
this->x1 = x1;
}
bool Box::intersects_cell(double *a, double *b) const{
for(int_t i=0; i<dim; ++i){
if(std::max(x0[i], x1[i]) < a[i]){
return false;
}
if(std::min(x0[i], x1[i]) > b[i]){
return false;
}
}
return true;
}
Plane::Plane() : Geometric(){
origin = NULL;
normal = NULL;
}
Plane::Plane(int_t dim, double* origin, double *normal) : Geometric(dim){
this->origin = origin;
this->normal = normal;
}
bool Plane::intersects_cell(double *a, double *b) const{
double center;
double half_width;
double s = 0.0;
double r = 0.0;
for(int_t i=0;i<dim;++i){
center = (b[i] + a[i]) * 0.5;
half_width = center - a[i];
r += half_width * std::abs(normal[i]);
s += normal[i] * (center - origin[i]);
}
return std::abs(s) <= r;
}
Triangle::Triangle() : Geometric(){
x0 = NULL;
x1 = NULL;
x2 = NULL;
for(int_t i=0; i<3; ++i){
e0[i] = 0.0;
e1[i] = 0.0;
e2[i] = 0.0;
normal[i] = 0.0;
}
}
Triangle::Triangle(int_t dim, double* x0, double *x1, double *x2) : Geometric(dim){
this->x0 = x0;
this->x1 = x1;
this->x2 = x2;
for(int_t i=0; i<dim; ++i){
e0[i] = x1[i] - x0[i];
e1[i] = x2[i] - x1[i];
e2[i] = x2[i] - x0[i];
}
if(dim > 2){
normal[0] = e0[1] * e1[2] - e0[2] * e1[1];
normal[1] = e0[2] * e1[0] - e0[0] * e1[2];
normal[2] = e0[0] * e1[1] - e0[1] * e1[0];
}
}
bool Triangle::intersects_cell(double *a, double *b) const{
double center;
double v0[3], v1[3], v2[3], half[3];
double vmin, vmax;
double p0, p1, p2, pmin, pmax, rad;
for(int_t i=0; i < dim; ++i){
center = 0.5 * (b[i] + a[i]);
v0[i] = x0[i] - center;
v1[i] = x1[i] - center;
vmin = std::min(v0[i], v1[i]);
vmax = std::max(v0[i], v1[i]);
v2[i] = x2[i] - center;
vmin = std::min(vmin, v2[i]);
vmax = std::max(vmax, v2[i]);
half[i] = center - a[i];
// Bounding box check
if (vmin > half[i] || vmax < -half[i]){
return false;
}
}
// first do the 3 edge cross tests that apply in 2D and 3D
// edge 0 cross z_hat
//p0 = e0[1] * v0[0] - e0[0] * v0[1];
p1 = e0[1] * v1[0] - e0[0] * v1[1];
p2 = e0[1] * v2[0] - e0[0] * v2[1];
pmin = std::min(p1, p2);
pmax = std::max(p1, p2);
rad = std::abs(e0[1]) * half[0] + std::abs(e0[0]) * half[1];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 1 cross z_hat
p0 = e1[1] * v0[0] - e1[0] * v0[1];
p1 = e1[1] * v1[0] - e1[0] * v1[1];
//p2 = e1[1] * v2[0] - e1[0] * v2[1];
pmin = std::min(p0, p1);
pmax = std::max(p0, p1);
rad = std::abs(e1[1]) * half[0] + std::abs(e1[0]) * half[1];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 2 cross z_hat
//p0 = e2[1] * v0[0] - e2[0] * v0[1];
p1 = e2[1] * v1[0] - e2[0] * v1[1];
p2 = e2[1] * v2[0] - e2[0] * v2[1];
pmin = std::min(p1, p2);
pmax = std::max(p1, p2);
rad = std::abs(e2[1]) * half[0] + std::abs(e2[0]) * half[1];
if (pmin > rad || pmax < -rad){
return false;
}
if(dim > 2){
// edge 0 cross x_hat
p0 = e0[2] * v0[1] - e0[1] * v0[2];
//p1 = e0[2] * v1[1] - e0[1] * v1[2];
p2 = e0[2] * v2[1] - e0[1] * v2[2];
pmin = std::min(p0, p2);
pmax = std::max(p0, p2);
rad = std::abs(e0[2]) * half[1] + std::abs(e0[1]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 0 cross y_hat
p0 = -e0[2] * v0[0] + e0[0] * v0[2];
//p1 = -e0[2] * v1[0] + e0[0] * v1[2];
p2 = -e0[2] * v2[0] + e0[0] * v2[2];
pmin = std::min(p0, p2);
pmax = std::max(p0, p2);
rad = std::abs(e0[2]) * half[0] + std::abs(e0[0]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 1 cross x_hat
p0 = e1[2] * v0[1] - e1[1] * v0[2];
//p1 = e1[2] * v1[1] - e1[1] * v1[2];
p2 = e1[2] * v2[1] - e1[1] * v2[2];
pmin = std::min(p0, p2);
pmax = std::max(p0, p2);
rad = std::abs(e1[2]) * half[1] + std::abs(e1[1]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 1 cross y_hat
p0 = -e1[2] * v0[0] + e1[0] * v0[2];
//p1 = -e1[2] * v1[0] + e1[0] * v1[2];
p2 = -e1[2] * v2[0] + e1[0] * v2[2];
pmin = std::min(p0, p2);
pmax = std::max(p0, p2);
rad = std::abs(e1[2]) * half[0] + std::abs(e1[0]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 2 cross x_hat
p0 = e2[2] * v0[1] - e2[1] * v0[2];
p1 = e2[2] * v1[1] - e2[1] * v1[2];
//p2 = e2[2] * v2[1] - e2[1] * v2[2];
pmin = std::min(p0, p1);
pmax = std::max(p0, p1);
rad = std::abs(e2[2]) * half[1] + std::abs(e2[1]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 2 cross y_hat
p0 = -e2[2] * v0[0] + e2[0] * v0[2];
p1 = -e2[2] * v1[0] + e2[0] * v1[2];
//p2 = -e2[2] * v2[0] + e2[0] * v2[2];
pmin = std::min(p0, p1);
pmax = std::max(p0, p1);
rad = std::abs(e2[2]) * half[0] + std::abs(e2[0]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// triangle normal axis
pmin = 0.0;
pmax = 0.0;
for(int_t i=0; i<dim; ++i){
if(normal[i] > 0){
pmin += normal[i] * (-half[i] - v0[i]);
pmax += normal[i] * (half[i] - v0[i]);
}else{
pmin += normal[i] * (half[i] - v0[i]);
pmax += normal[i] * (-half[i] - v0[i]);
}
}
if (pmin > 0 || pmax < 0){
return false;
}
}
return true;
}
VerticalTriangularPrism::VerticalTriangularPrism() : Triangle(){
h = 0;
}
VerticalTriangularPrism::VerticalTriangularPrism(int_t dim, double* x0, double *x1, double *x2, double h) : Triangle(dim, x0, x1, x2){
this->h = h;
}
bool VerticalTriangularPrism::intersects_cell(double *a, double *b) const{
double center;
double v0[3], v1[3], v2[3], half[3];
double vmin, vmax;
double p0, p1, p2, p3, pmin, pmax, rad;
for(int_t i=0; i < dim; ++i){
center = 0.5 * (a[i] + b[i]);
v0[i] = x0[i] - center;
v1[i] = x1[i] - center;
vmin = std::min(v0[i], v1[i]);
vmax = std::max(v0[i], v1[i]);
v2[i] = x2[i] - center;
vmin = std::min(vmin, v2[i]);
vmax = std::max(vmax, v2[i]);
if(i == 2){
vmax += h;
}
half[i] = center - a[i];
// Bounding box check
if (vmin > half[i] || vmax < -half[i]){
return false;
}
}
// first do the 3 edge cross tests that apply in 2D and 3D
// edge 0 cross z_hat
//p0 = e0[1] * v0[0] - e0[0] * v0[1];
p1 = e0[1] * v1[0] - e0[0] * v1[1];
p2 = e0[1] * v2[0] - e0[0] * v2[1];
pmin = std::min(p1, p2);
pmax = std::max(p1, p2);
rad = std::abs(e0[1]) * half[0] + std::abs(e0[0]) * half[1];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 1 cross z_hat
p0 = e1[1] * v0[0] - e1[0] * v0[1];
p1 = e1[1] * v1[0] - e1[0] * v1[1];
//p2 = e1[1] * v2[0] - e1[0] * v2[1];
pmin = std::min(p0, p1);
pmax = std::max(p0, p1);
rad = std::abs(e1[1]) * half[0] + std::abs(e1[0]) * half[1];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 2 cross z_hat
//p0 = e2[1] * v0[0] - e2[0] * v0[1];
p1 = e2[1] * v1[0] - e2[0] * v1[1];
p2 = e2[1] * v2[0] - e2[0] * v2[1];
pmin = std::min(p1, p2);
pmax = std::max(p1, p2);
rad = std::abs(e2[1]) * half[0] + std::abs(e2[0]) * half[1];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 0 cross x_hat
p0 = e0[2] * v0[1] - e0[1] * v0[2];
p1 = e0[2] * v0[1] - e0[1] * (v0[2] + h);
p2 = e0[2] * v2[1] - e0[1] * v2[2];
p3 = e0[2] * v2[1] - e0[1] * (v2[2] + h);
pmin = std::min(std::min(std::min(p0, p1), p2), p3);
pmax = std::max(std::max(std::max(p0, p1), p2), p3);
rad = std::abs(e0[2]) * half[1] + std::abs(e0[1]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 0 cross y_hat
p0 = -e0[2] * v0[0] + e0[0] * v0[2];
p1 = -e0[2] * v0[0] + e0[0] * (v0[2] + h);
p2 = -e0[2] * v2[0] + e0[0] * v2[2];
p3 = -e0[2] * v2[0] + e0[0] * (v2[2] + h);
pmin = std::min(std::min(std::min(p0, p1), p2), p3);
pmax = std::max(std::max(std::max(p0, p1), p2), p3);
rad = std::abs(e0[2]) * half[0] + std::abs(e0[0]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 1 cross x_hat
p0 = e1[2] * v0[1] - e1[1] * v0[2];
p1 = e1[2] * v0[1] - e1[1] * (v0[2] + h);
p2 = e1[2] * v2[1] - e1[1] * v2[2];
p3 = e1[2] * v2[1] - e1[1] * (v2[2] + h);
pmin = std::min(std::min(std::min(p0, p1), p2), p3);
pmax = std::max(std::max(std::max(p0, p1), p2), p3);
rad = std::abs(e1[2]) * half[1] + std::abs(e1[1]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 1 cross y_hat
p0 = -e1[2] * v0[0] + e1[0] * v0[2];
p1 = -e1[2] * v0[0] + e1[0] * (v0[2] + h);
p2 = -e1[2] * v2[0] + e1[0] * v2[2];
p3 = -e1[2] * v2[0] + e1[0] * (v2[2] + h);
pmin = std::min(std::min(std::min(p0, p1), p2), p3);
pmax = std::max(std::max(std::max(p0, p1), p2), p3);
rad = std::abs(e1[2]) * half[0] + std::abs(e1[0]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 2 cross x_hat
p0 = e2[2] * v0[1] - e2[1] * v0[2];
p1 = e2[2] * v0[1] - e2[1] * (v0[2] + h);
p2 = e2[2] * v1[1] - e2[1] * v1[2];
p3 = e2[2] * v1[1] - e2[1] * (v1[2] + h);
pmin = std::min(std::min(std::min(p0, p1), p2), p3);
pmax = std::max(std::max(std::max(p0, p1), p2), p3);
rad = std::abs(e2[2]) * half[1] + std::abs(e2[1]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// edge 2 cross y_hat
p0 = -e2[2] * v0[0] + e2[0] * v0[2];
p1 = -e2[2] * v0[0] + e2[0] * (v0[2] + h);
p2 = -e2[2] * v1[0] + e2[0] * v1[2];
p3 = -e2[2] * v1[0] + e2[0] * (v1[2] + h);
pmin = std::min(std::min(std::min(p0, p1), p2), p3);
pmax = std::max(std::max(std::max(p0, p1), p2), p3);
rad = std::abs(e2[2]) * half[0] + std::abs(e2[0]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// triangle normal axis
p0 = normal[0] * v0[0] + normal[1] * v0[1] + normal[2] * v0[2];
p1 = normal[0] * v0[0] + normal[1] * v0[1] + normal[2] * (v0[2] + h);
pmin = std::min(p0, p1);
pmax = std::max(p0, p1);
rad = std::abs(normal[0]) * half[0] + std::abs(normal[1]) * half[1] + std::abs(normal[2]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
// the axes defined by the three vertical prism faces
// should already be tested by the e0, e1, e2 cross z_hat tests
return true;
}
Tetrahedron::Tetrahedron() : Geometric(){
x0 = NULL;
x1 = NULL;
x2 = NULL;
x3 = NULL;
for(int_t i=0; i<6; ++i){
for(int_t j=0; j<3; ++j){
edge_tans[i][j] = 0.0;
}
}
for(int_t i=0; i<4; ++i){
for(int_t j=0; j<3; ++j){
face_normals[i][j] = 0.0;
}
}
}
Tetrahedron::Tetrahedron(int_t dim, double* x0, double *x1, double *x2, double *x3) : Geometric(dim){
this->x0 = x0;
this->x1 = x1;
this->x2 = x2;
this->x3 = x3;
for(int_t i=0; i<dim; ++i){
edge_tans[0][i] = x1[i] - x0[i];
edge_tans[1][i] = x2[i] - x0[i];
edge_tans[2][i] = x2[i] - x1[i];
edge_tans[3][i] = x3[i] - x0[i];
edge_tans[4][i] = x3[i] - x1[i];
edge_tans[5][i] = x3[i] - x2[i];
}
// cross e0, e1 (x0, x1, x2)
CROSS3D(edge_tans[0], edge_tans[1], face_normals[0])
// cross e0, e3 (x0, x1, x3)
CROSS3D(edge_tans[0], edge_tans[3], face_normals[1])
// cross e1, e3 (x0, x2, x3)
CROSS3D(edge_tans[1], edge_tans[3], face_normals[2])
// cross e2, e5 (x1, x2, x3)
CROSS3D(edge_tans[2], edge_tans[5], face_normals[3])
}
bool Tetrahedron::intersects_cell(double *a, double *b) const{
double v0[3], v1[3], v2[3], v3[3], half[3];
double p0, p1, p2, p3, pmin, pmax, rad;
double center;
for(int_t i=0; i < dim; ++i){
center = 0.5 * (a[i] + b[i]);
v0[i] = x0[i] - center;
v1[i] = x1[i] - center;
v2[i] = x2[i] - center;
v3[i] = x3[i] - center;
half[i] = center - a[i];
pmin = std::min(std::min(std::min(v0[i], v1[i]), v2[i]), v3[i]);
pmax = std::max(std::max(std::max(v0[i], v1[i]), v2[i]), v3[i]);
// Bounding box check
if (pmin > half[i] || pmax < -half[i]){
return false;
}
}
// first do the 3 edge cross tests that apply in 2D and 3D
const double *axis;
for(int_t i=0; i<6; ++i){
// edge cross [1, 0, 0]
p0 = edge_tans[i][2] * v0[1] - edge_tans[i][1] * v0[2];
p1 = edge_tans[i][2] * v1[1] - edge_tans[i][1] * v1[2];
p2 = edge_tans[i][2] * v2[1] - edge_tans[i][1] * v2[2];
p3 = edge_tans[i][2] * v3[1] - edge_tans[i][1] * v3[2];
pmin = std::min(std::min(std::min(p0, p1), p2), p3);
pmax = std::max(std::max(std::max(p0, p1), p2), p3);
rad = std::abs(edge_tans[i][2]) * half[1] + std::abs(edge_tans[i][1]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
p0 = -edge_tans[i][2] * v0[0] + edge_tans[i][0] * v0[2];
p1 = -edge_tans[i][2] * v1[0] + edge_tans[i][0] * v1[2];
p2 = -edge_tans[i][2] * v2[0] + edge_tans[i][0] * v2[2];
p3 = -edge_tans[i][2] * v3[0] + edge_tans[i][0] * v3[2];
pmin = std::min(std::min(std::min(p0, p1), p2), p3);
pmax = std::max(std::max(std::max(p0, p1), p2), p3);
rad = std::abs(edge_tans[i][2]) * half[0] + std::abs(edge_tans[i][0]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
p0 = edge_tans[i][1] * v0[0] - edge_tans[i][0] * v0[1];
p1 = edge_tans[i][1] * v1[0] - edge_tans[i][0] * v1[1];
p2 = edge_tans[i][1] * v2[0] - edge_tans[i][0] * v2[1];
p3 = edge_tans[i][1] * v3[0] - edge_tans[i][0] * v3[1];
pmin = std::min(std::min(std::min(p0, p1), p2), p3);
pmax = std::max(std::max(std::max(p0, p1), p2), p3);
rad = std::abs(edge_tans[i][1]) * half[0] + std::abs(edge_tans[i][0]) * half[1];
if (pmin > rad || pmax < -rad){
return false;
}
}
// triangle face normals
for(int_t i=0; i<4; ++i){
axis = face_normals[i];
p0 = axis[0] * v0[0] + axis[1] * v0[1] + axis[2] * v0[2];
p1 = axis[0] * v1[0] + axis[1] * v1[1] + axis[2] * v1[2];
p2 = axis[0] * v2[0] + axis[1] * v2[1] + axis[2] * v2[2];
p3 = axis[0] * v3[0] + axis[1] * v3[1] + axis[2] * v3[2];
pmin = std::min(std::min(std::min(p0, p1), p2), p3);
pmax = std::max(std::max(std::max(p0, p1), p2), p3);
rad = std::abs(axis[0]) * half[0] + std::abs(axis[1]) * half[1] + std::abs(axis[2]) * half[2];
if (pmin > rad || pmax < -rad){
return false;
}
}
return true;
}
================================================
FILE: discretize/_extensions/geom.h
================================================
#ifndef __GEOM_H
#define __GEOM_H
// simple geometric objects for intersection tests with an aabb
typedef std::size_t int_t;
class Geometric{
public:
int_t dim;
Geometric();
Geometric(int_t dim);
virtual bool intersects_cell(double *a, double *b) const = 0;
};
class Ball : public Geometric{
public:
double *x0;
double r;
double rsq;
Ball();
Ball(int_t dim, double* x0, double r);
virtual bool intersects_cell(double *a, double *b) const;
};
class Line : public Geometric{
public:
double *x0;
double *x1;
double inv_dx[3];
Line();
Line(int_t dim, double* x0, double *x1);
virtual bool intersects_cell(double *a, double *b) const;
};
class Box : public Geometric{
public:
double *x0;
double *x1;
Box();
Box(int_t dim, double* x0, double *x1);
virtual bool intersects_cell(double *a, double *b) const;
};
class Plane : public Geometric{
public:
double *origin;
double *normal;
Plane();
Plane(int_t dim, double* origin, double *normal);
virtual bool intersects_cell(double *a, double *b) const;
};
class Triangle : public Geometric{
public:
double *x0;
double *x1;
double *x2;
double e0[3];
double e1[3];
double e2[3];
double normal[3];
Triangle();
Triangle(int_t dim, double* x0, double *x1, double *x2);
virtual bool intersects_cell(double *a, double *b) const;
};
class VerticalTriangularPrism : public Triangle{
public:
double h;
VerticalTriangularPrism();
VerticalTriangularPrism(int_t dim, double* x0, double *x1, double *x2, double h);
virtual bool intersects_cell(double *a, double *b) const;
};
class Tetrahedron : public Geometric{
public:
double *x0;
double *x1;
double *x2;
double *x3;
double edge_tans[6][3];
double face_normals[4][3];
Tetrahedron();
Tetrahedron(int_t dim, double* x0, double *x1, double *x2, double *x3);
virtual bool intersects_cell(double *a, double *b) const;
};
#endif
================================================
FILE: discretize/_extensions/geom.pxd
================================================
from libcpp cimport bool
cdef extern from "geom.h":
ctypedef int int_t
cdef cppclass Ball:
Ball() except +
Ball(int_t dim, double * x0, double r) except +
cdef cppclass Line:
Line() except +
Line(int_t dim, double * x0, double *x1) except +
cdef cppclass Box:
Box() except +
Box(int_t dim, double * x0, double *x1) except +
cdef cppclass Plane:
Plane() except +
Plane(int_t dim, double * origin, double *normal) except +
cdef cppclass Triangle:
Triangle() except +
Triangle(int_t dim, double * x0, double *x1, double *x2) except +
cdef cppclass VerticalTriangularPrism:
VerticalTriangularPrism() except +
VerticalTriangularPrism(int_t dim, double * x0, double *x1, double *x2, double h) except +
cdef cppclass Tetrahedron:
Tetrahedron() except +
Tetrahedron(int_t dim, double * x0, double *x1, double *x2, double *x3) except +
================================================
FILE: discretize/_extensions/interputils_cython.pxd
================================================
cimport numpy as np
cdef np.int64_t _bisect_left(np.float64_t[:] a, np.float64_t x) nogil
cdef np.int64_t _bisect_right(np.float64_t[:] a, np.float64_t x) nogil
================================================
FILE: discretize/_extensions/interputils_cython.pyx
================================================
# cython: embedsignature=True, language_level=3
# cython: linetrace=True
# cython: freethreading_compatible = True
import numpy as np
import cython
cimport numpy as np
import scipy.sparse as sp
def _interp_point_1D(np.ndarray[np.float64_t, ndim=1] x, float xr_i):
"""
given a point, xr_i, this will find which two integers it lies between.
:param numpy.ndarray x: Tensor vector of 1st dimension of grid.
:param float xr_i: Location of a point
:rtype: int,int,float,float
:return: index1, index2, portion1, portion2
"""
cdef IIFF xs
_get_inds_ws(x,xr_i,&xs)
return xs.i1,xs.i2,xs.w1,xs.w2
cdef struct IIFF:
np.int64_t i1,i2
np.float64_t w1,w2
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.nonecheck(False)
cdef np.int64_t _bisect_left(np.float64_t[:] a, np.float64_t x) nogil:
cdef np.int64_t lo, hi, mid
lo = 0
hi = a.shape[0]
while lo < hi:
mid = (lo+hi)//2
if a[mid] < x: lo = mid+1
else: hi = mid
return lo
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.nonecheck(False)
cdef np.int64_t _bisect_right(np.float64_t[:] a, np.float64_t x) nogil:
cdef np.int64_t lo, hi, mid
lo = 0
hi = a.shape[0]
while lo < hi:
mid = (lo+hi)//2
if x < a[mid]: hi = mid
else: lo = mid+1
return lo
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.nonecheck(False)
@cython.cdivision(True)
cdef void _get_inds_ws(np.float64_t[:] x, np.float64_t xp, IIFF* out) nogil:
cdef np.int64_t ind = _bisect_right(x,xp)
cdef np.int64_t nx = x.shape[0]
out.i2 = ind
out.i1 = ind-1
out.i2 = max(min(out.i2,nx-1),0)
out.i1 = max(min(out.i1,nx-1),0)
if(out.i1==out.i2):
out.w1 = 0.5
else:
out.w1 = (x[out.i2]-xp)/(x[out.i2]-x[out.i1])
out.w2 = 1-out.w1
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.nonecheck(False)
def _interpmat1D(np.ndarray[np.float64_t, ndim=1] locs,
np.ndarray[np.float64_t, ndim=1] x):
cdef int nx = x.size
cdef IIFF xs
cdef int npts = locs.shape[0]
cdef int i
cdef np.ndarray[np.int64_t,ndim=1] inds = np.empty(npts*2,dtype=np.int64)
cdef np.ndarray[np.float64_t,ndim=1] vals = np.empty(npts*2,dtype=np.float64)
for i in range(npts):
_get_inds_ws(x,locs[i],&xs)
inds[2*i ] = xs.i1
inds[2*i+1] = xs.i2
vals[2*i ] = xs.w1
vals[2*i+1] = xs.w2
return inds,vals
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.nonecheck(False)
def _interpmat2D(np.ndarray[np.float64_t, ndim=2] locs,
np.ndarray[np.float64_t, ndim=1] x,
np.ndarray[np.float64_t, ndim=1] y):
cdef int nx,ny
nx,ny = len(x),len(y)
cdef int npts = locs.shape[0]
cdef int i
cdef IIFF xs,ys
cdef np.ndarray[np.int64_t,ndim=2] inds = np.empty((npts*4,2),dtype=np.int64)
cdef np.ndarray[np.float64_t,ndim=1] vals = np.empty(npts*4,dtype=np.float64)
for i in range(npts):
_get_inds_ws(x,locs[i,0],&xs)
_get_inds_ws(y,locs[i,1],&ys)
inds[4*i ,0] = xs.i1
inds[4*i+1,0] = xs.i1
inds[4*i+2,0] = xs.i2
inds[4*i+3,0] = xs.i2
inds[4*i ,1] = ys.i1
inds[4*i+1,1] = ys.i2
inds[4*i+2,1] = ys.i1
inds[4*i+3,1] = ys.i2
vals[4*i ] = xs.w1*ys.w1
vals[4*i+1] = xs.w1*ys.w2
vals[4*i+2] = xs.w2*ys.w1
vals[4*i+3] = xs.w2*ys.w2
return inds,vals
@cython.boundscheck(False)
@cython.wraparound(False)
@cython.nonecheck(False)
def _interpmat3D(np.ndarray[np.float64_t, ndim=2] locs,
np.ndarray[np.float64_t, ndim=1] x,
np.ndarray[np.float64_t, ndim=1] y,
np.ndarray[np.float64_t, ndim=1] z):
cdef int nx,ny,nz
nx,ny,nz = len(x),len(y),len(z)
cdef IIFF xs,ys,zs
cdef int npts = locs.shape[0]
cdef int i
cdef np.ndarray[np.int64_t,ndim=2] inds = np.empty((npts*8,3),dtype=np.int64)
cdef np.ndarray[np.float64_t,ndim=1] vals = np.empty(npts*8,dtype=np.float64)
for i in range(npts):
_get_inds_ws(x,locs[i,0],&xs)
_get_inds_ws(y,locs[i,1],&ys)
_get_inds_ws(z,locs[i,2],&zs)
inds[8*i ,0] = xs.i1
inds[8*i+1,0] = xs.i1
inds[8*i+2,0] = xs.i2
inds[8*i+3,0] = xs.i2
inds[8*i+4,0] = xs.i1
inds[8*i+5,0] = xs.i1
inds[8*i+6,0] = xs.i2
inds[8*i+7,0] = xs.i2
inds[8*i ,1] = ys.i1
inds[8*i+1,1] = ys.i2
inds[8*i+2,1] = ys.i1
inds[8*i+3,1] = ys.i2
inds[8*i+4,1] = ys.i1
inds[8*i+5,1] = ys.i2
inds[8*i+6,1] = ys.i1
inds[8*i+7,1] = ys.i2
inds[8*i ,2] = zs.i1
inds[8*i+1,2] = zs.i1
inds[8*i+2,2] = zs.i1
inds[8*i+3,2] = zs.i1
inds[8*i+4,2] = zs.i2
inds[8*i+5,2] = zs.i2
inds[8*i+6,2] = zs.i2
inds[8*i+7,2] = zs.i2
vals[8*i ] = xs.w1*ys.w1*zs.w1
vals[8*i+1] = xs.w1*ys.w2*zs.w1
vals[8*i+2] = xs.w2*ys.w1*zs.w1
vals[8*i+3] = xs.w2*ys.w2*zs.w1
vals[8*i+4] = xs.w1*ys.w1*zs.w2
vals[8*i+5] = xs.w1*ys.w2*zs.w2
vals[8*i+6] = xs.w2*ys.w1*zs.w2
vals[8*i+7] = xs.w2*ys.w2*zs.w2
return inds,vals
@cython.boundscheck(False)
@cython.cdivision(True)
def _tensor_volume_averaging(mesh_in, mesh_out, values=None, output=None):
cdef np.int32_t[:] i1_in, i1_out, i2_in, i2_out, i3_in, i3_out
cdef np.float64_t[:] w1, w2, w3
w1 = np.array([1.0], dtype=np.float64)
w2 = np.array([1.0], dtype=np.float64)
w3 = np.array([1.0], dtype=np.float64)
i1_in = np.array([0], dtype=np.int32)
i1_out = np.array([0], dtype=np.int32)
i2_in = np.array([0], dtype=np.int32)
i2_out = np.array([0], dtype=np.int32)
i3_in = np.array([0], dtype=np.int32)
i3_out = np.array([0], dtype=np.int32)
cdef int dim = mesh_in.dim
w1, i1_in, i1_out = _volume_avg_weights(mesh_in.nodes_x, mesh_out.nodes_x)
if dim > 1:
w2, i2_in, i2_out = _volume_avg_weights(mesh_in.nodes_y, mesh_out.nodes_y)
if dim > 2:
w3, i3_in, i3_out = _volume_avg_weights(mesh_in.nodes_z, mesh_out.nodes_z)
cdef (np.int32_t, np.int32_t, np.int32_t) w_shape = (w1.shape[0], w2.shape[0], w3.shape[0])
cdef (np.int32_t, np.int32_t, np.int32_t) mesh_in_shape
cdef (np.int32_t, np.int32_t, np.int32_t) mesh_out_shape
nCv_in = [len(h) for h in mesh_in.h]
nCv_out = [len(h) for h in mesh_out.h]
if dim == 1:
mesh_in_shape = (nCv_in[0], 1, 1)
mesh_out_shape = (nCv_out[0], 1, 1)
elif dim == 2:
mesh_in_shape = (nCv_in[0], nCv_in[1], 1)
mesh_out_shape = (nCv_out[0], nCv_out[1], 1)
elif dim == 3:
mesh_in_shape = (*nCv_in, )
mesh_out_shape = (*nCv_out, )
cdef np.float64_t[::1, :, :] val_in
cdef np.float64_t[::1, :, :] val_out
cdef int i1, i2, i3, i1i, i2i, i3i, i1o, i2o, i3o
cdef np.float64_t w_3, w_32
cdef np.float64_t[::1, :, :] vol = mesh_out.cell_volumes.reshape(mesh_out_shape, order='F').astype(np.float64)
if values is not None:
# If given a values array, do the operation
val_in = values.reshape(mesh_in_shape, order='F').astype(np.float64)
if output is None:
output = np.zeros(mesh_out.n_cells, dtype=np.float64)
else:
output = np.require(output, dtype=np.float64, requirements=['A', 'W'])
v_o = output.reshape(mesh_out_shape, order='F')
v_o.fill(0)
val_out = v_o
for i3 in range(w_shape[2]):
i3i = i3_in[i3]
i3o = i3_out[i3]
w_3 = w3[i3]
for i2 in range(w_shape[1]):
i2i = i2_in[i2]
i2o = i2_out[i2]
w_32 = w_3*w2[i2]
for i1 in range(w_shape[0]):
i1i = i1_in[i1]
i1o = i1_out[i1]
val_out[i1o, i2o, i3o] += w_32*w1[i1]*val_in[i1i, i2i, i3i]/vol[i1o, i2o, i3o]
return output
# Else, build and return a sparse matrix representing the operation
i_i = np.empty(w_shape, dtype=np.int32, order='F')
i_o = np.empty(w_shape, dtype=np.int32, order='F')
ws = np.empty(w_shape, dtype=np.float64, order='F')
cdef np.int32_t[::1,:,:] i_in = i_i
cdef np.int32_t[::1,:,:] i_out = i_o
cdef np.float64_t[::1, :, :] w = ws
for i3 in range(w.shape[2]):
i3i = i3_in[i3]
i3o = i3_out[i3]
w_3 = w3[i3]
for i2 in range(w.shape[1]):
i2i = i2_in[i2]
i2o = i2_out[i2]
w_32 = w_3*w2[i2]
for i1 in range(w.shape[0]):
i1i = i1_in[i1]
i1o = i1_out[i1]
w[i1, i2, i3] = w_32*w1[i1]/vol[i1o, i2o, i3o]
i_in[i1, i2, i3] = (i3i*mesh_in_shape[1] + i2i)*mesh_in_shape[0] + i1i
i_out[i1, i2, i3] = (i3o*mesh_out_shape[1] + i2o)*mesh_out_shape[0] + i1o
ws = ws.reshape(-1, order='F')
i_i = i_i.reshape(-1, order='F')
i_o = i_o.reshape(-1, order='F')
A = sp.csr_matrix((ws, (i_o, i_i)), shape=(mesh_out.nC, mesh_in.nC))
return A
@cython.boundscheck(False)
def _volume_avg_weights(np.float64_t[:] x1, np.float64_t[:] x2):
cdef int n1 = x1.shape[0]
cdef int n2 = x2.shape[0]
cdef np.float64_t[:] xs = np.empty(n1 + n2)
# Fill xs with uniques and truncate
cdef int i1, i2, i, ii
i1 = i2 = i = 0
while i1<n1 or i2<n2:
if i1<n1 and i2<n2:
if x1[i1]<x2[i2]:
xs[i] = x1[i1]
i1 += 1
elif x1[i1]>x2[i2]:
xs[i] = x2[i2]
i2 += 1
else:
xs[i] = x1[i1]
i1 += 1
i2 += 1
elif i1<n1 and i2==n2:
xs[i] = x1[i1]
i1 += 1
elif i2<n2 and i1==n1:
xs[i] = x2[i2]
i2 += 1
i += 1
cdef int nh = i-1
hs = np.empty(nh)
ix1 = np.empty(nh, dtype=np.int32)
ix2 = np.empty(nh, dtype=np.int32)
cdef np.float64_t[:] _hs = hs
cdef np.int32_t[:] _ix1 = ix1
cdef np.int32_t[:] _ix2 = ix2
cdef np.float64_t center
i1 = i2 = ii = 0
for i in range(nh):
center = 0.5*(xs[i]+xs[i+1])
if x2[0] <= center and center <= x2[n2-1]:
_hs[ii] = xs[i+1]-xs[i]
while i1<n1-1 and center>=x1[i1]:
i1 += 1
while i2<n2-1 and center>=x2[i2]:
i2 += 1
_ix1[ii] = min(max(i1-1, 0), n1-1)
_ix2[ii] = min(max(i2-1, 0), n2-1)
ii += 1
hs = hs[:ii]
ix1 = ix1[:ii]
ix2 = ix2[:ii]
return hs, ix1, ix2
================================================
FILE: discretize/_extensions/meson.build
================================================
# NumPy include directory
numpy_nodepr_api = ['-DNPY_NO_DEPRECATED_API=NPY_1_22_API_VERSION']
np_dep = dependency('numpy')
# Deal with M_PI & friends; add `use_math_defines` to c_args or cpp_args
# Cython doesn't always get this right itself (see, e.g., gh-16800), so
# explicitly add the define as a compiler flag for Cython-generated code.
is_windows = host_machine.system() == 'windows'
if is_windows
use_math_defines = ['-D_USE_MATH_DEFINES']
else
use_math_defines = []
endif
c_undefined_ok = ['-Wno-maybe-uninitialized']
cython_c_args = [numpy_nodepr_api, use_math_defines]
cy_line_trace = get_option('cy_line_trace')
if cy_line_trace
cython_c_args += ['-DCYTHON_TRACE_NOGIL=1']
endif
cython_args = []
if cy.version().version_compare('>=3.1.0')
cython_args += ['-Xfreethreading_compatible=True']
endif
cython_cpp_args = cython_c_args
module_path = 'discretize/_extensions'
py.extension_module(
'interputils_cython',
'interputils_cython.pyx',
cython_args: cython_args,
c_args: cython_c_args,
install: true,
subdir: module_path,
dependencies : [py_dep, np_dep],
)
py.extension_module(
'tree_ext',
['tree_ext.pyx' , 'tree.cpp', 'geom.cpp'],
cython_args: cython_args,
cpp_args: cython_cpp_args,
install: true,
subdir: module_path,
dependencies : [py_dep, np_dep],
override_options : ['cython_language=cpp'],
)
py.extension_module(
'simplex_helpers',
'simplex_helpers.pyx',
cython_args: cython_args,
cpp_args: cython_cpp_args,
install: true,
subdir: module_path,
dependencies : [py_dep, np_dep],
override_options : ['cython_language=cpp'],
)
python_sources = [
'__init__.py',
]
py.install_sources(
python_sources,
subdir: module_path
)
================================================
FILE: discretize/_extensions/simplex_helpers.pyx
================================================
# distutils: language=c++
# cython: embedsignature=True, language_level=3
# cython: linetrace=True
# cython: freethreading_compatible = True
from libcpp.pair cimport pair
from libcpp.unordered_map cimport unordered_map
from cython.operator cimport dereference
cimport cython
cimport numpy as np
from cython cimport view
from libc.math cimport sqrt
cdef extern from "triplet.h":
cdef cppclass triplet[T, U, V]:
T v1
U v2
V v3
triplet()
triplet(T, U, V)
import numpy as np
ctypedef fused ints:
size_t
np.int32_t
np.int64_t
ctypedef fused pointers:
size_t
np.intp_t
np.int32_t
np.int64_t
@cython.boundscheck(False)
def _build_faces_edges(ints[:, :] simplices):
# the node index in each simplex must be in increasing order
cdef:
int dim = simplices.shape[1] - 1
ints n_simplex = simplices.shape[0]
ints[:] simplex
ints v1, v2, v3
unordered_map[pair[ints, ints], ints] edges
pair[ints, ints] edge
ints n_edges = 0
ints edges_per_simplex = 3 if dim==2 else 6
ints[:, :] simplex_edges
unordered_map[triplet[ints, ints, ints], ints] faces
triplet[ints, ints, ints] face
ints n_faces = 0
ints faces_per_simplex = dim + 1
ints[:, :] simplex_faces
if ints is size_t:
int_type = np.uintp
elif ints is np.int32_t:
int_type = np.int32
elif ints is np.int64_t:
int_type = np.int64
simplex_edges = np.empty((n_simplex, edges_per_simplex), dtype=int_type)
if dim == 3:
simplex_faces = np.empty((n_simplex, faces_per_simplex), dtype=int_type)
else:
simplex_faces = simplex_edges
cdef ints[:,:] edge_pairs = np.array(
[[1, 2], [0, 2], [0, 1], [0, 3], [1, 3], [2, 3]],
dtype=int_type
)
for i_simp in range(n_simplex):
simplex = simplices[i_simp]
# build edges
for i_edge in range(edges_per_simplex):
v1 = simplex[edge_pairs[i_edge, 0]]
v2 = simplex[edge_pairs[i_edge, 1]]
edge = pair[ints, ints](v1, v2)
edge_search = edges.find(edge)
if edge_search != edges.end():
ind = dereference(edge_search).second
else:
ind = n_edges
edges[edge] = ind
n_edges += 1
simplex_edges[i_simp, i_edge] = ind
# build faces in 3D
if dim == 3:
for i_face in range(4):
if i_face == 0:
v1 = simplex[1]
v2 = simplex[2]
v3 = simplex[3]
elif i_face == 1:
v1 = simplex[0]
v2 = simplex[2]
v3 = simplex[3]
elif i_face == 2:
v1 = simplex[0]
v2 = simplex[1]
v3 = simplex[3]
else:
v1 = simplex[0]
v2 = simplex[1]
v3 = simplex[2]
face = triplet[ints, ints, ints](v1, v2, v3)
face_search = faces.find(face)
if face_search != faces.end():
ind = dereference(face_search).second
else:
ind = n_faces
faces[face] = ind
n_faces += 1
simplex_faces[i_simp, i_face] = ind
cdef ints[:, :] _edges = np.empty((n_edges, 2), dtype=int_type)
for edge_it in edges:
_edges[edge_it.second, 0] = edge_it.first.first
_edges[edge_it.second, 1] = edge_it.first.second
cdef ints[:, :] _faces
if dim == 3:
_faces = np.empty((n_faces, 3), dtype=int_type)
for face_it in faces:
_faces[face_it.second, 0] = face_it.first.v1
_faces[face_it.second, 1] = face_it.first.v2
_faces[face_it.second, 2] = face_it.first.v3
else:
_faces = _edges
cdef ints[:, :] face_edges
cdef ints[:] _face
if dim == 3:
face_edges = np.empty((n_faces, 3), dtype=int_type)
for i_face in range(n_faces):
_face = _faces[i_face]
# get indices of each edge in the face
# 3 edges per face
for i_edge in range(3):
if i_edge == 0:
v1 = _face[1]
v2 = _face[2]
elif i_edge == 1:
v1 = _face[0]
v2 = _face[2]
elif i_edge == 2:
v1 = _face[0]
v2 = _face[1]
# because of how faces were constructed, v1 < v2 always
edge = pair[ints, ints](v1, v2)
ind = edges[edge]
face_edges[i_face, i_edge] = ind
else:
face_edges = np.empty((1, 1), dtype=int_type)
return simplex_faces, _faces, simplex_edges, _edges, face_edges
@cython.boundscheck(False)
def _build_adjacency(ints[:, :] simplex_faces, n_faces):
cdef:
size_t n_cells = simplex_faces.shape[0]
int dim = simplex_faces.shape[1] - 1
np.int64_t[:, :] neighbors
np.int64_t[:] visited
ints[:] simplex
ints i_cell, j, k, i_face, i_other
if ints is size_t:
int_type = np.uintp
elif ints is np.int32_t:
int_type = np.int32
elif ints is np.int64_t:
int_type = np.int64
neighbors = np.full((n_cells, dim + 1), -1, dtype=np.int64)
visited = np.full((n_faces), -1, dtype=np.int64)
for i_cell in range(n_cells):
simplex = simplex_faces[i_cell]
for j in range(dim + 1):
i_face = simplex[j]
i_other = visited[i_face]
if i_other == -1:
visited[i_face] = i_cell
else:
neighbors[i_cell, j] = i_other
k = 0
while (k < dim + 1) and (simplex_faces[i_other, k] != i_face):
k += 1
neighbors[i_other, k] = i_cell
return neighbors
@cython.boundscheck(False)
@cython.linetrace(False)
cdef void _compute_bary_coords(
np.float64_t[:] point,
np.float64_t[:, :] Tinv,
np.float64_t[:] shift,
np.float64_t * bary
) nogil:
cdef:
int dim = point.shape[0]
int i, j
bary[dim] = 1.0
for i in range(dim):
bary[i] = 0.0
for j in range(dim):
bary[i] += Tinv[i, j] * (point[j] - shift[j])
bary[dim] -= bary[i]
@cython.boundscheck(False)
def _directed_search(
np.float64_t[:, :] locs,
pointers[:] nearest_cc,
np.float64_t[:, :] nodes,
ints[:, :] simplex_nodes,
np.int64_t[:, :] neighbors,
np.float64_t[:, :, :] transform,
np.float64_t[:, :] shift,
np.float64_t eps=1E-15,
bint zeros_outside=False,
bint return_bary=True
):
cdef:
int i, j
pointers i_simp
int n_locs = locs.shape[0], dim = locs.shape[1]
int max_directed = 1 + simplex_nodes.shape[0] // 4
int i_directed
bint is_inside
np.int64_t[:] inds = np.full(len(locs), -1, dtype=np.int64)
np.float64_t[:, :] all_barys = np.empty((1, 1), dtype=np.float64)
np.float64_t barys[4]
np.float64_t[:] loc
np.float64_t[:, :] Tinv
np.float64_t[:] rD
if return_bary:
all_barys = np.empty((len(locs), dim+1), dtype=np.float64)
for i in range(n_locs):
loc = locs[i]
i_simp = nearest_cc[i] # start at the nearest cell center
i_directed = 0
while i_directed < max_directed:
Tinv = transform[i_simp]
rD = shift[i_simp]
_compute_bary_coords(loc, Tinv, rD, barys)
j = 0
is_inside = True
while j <= dim:
if barys[j] < -eps:
is_inside = False
# if not -1, move towards neighbor
if neighbors[i_simp, j] != -1:
i_simp = neighbors[i_simp, j]
break
j += 1
# If inside, I found my container
if is_inside:
break
# Else, if I cycled through every bary
# without breaking out of the above loop, that means I'm completely outside
elif j == dim + 1:
if zeros_outside:
i_simp = -1
break
i_directed += 1
if i_directed == max_directed:
# made it through the whole loop without breaking out
# Mark as failed
i_simp = -2
inds[i] = i_simp
if return_bary:
for j in range(dim+1):
all_barys[i, j] = barys[j]
if return_bary:
return np.array(inds), np.array(all_barys)
return np.array(inds)
@cython.boundscheck(False)
@cython.cdivision(True)
def _interp_cc(
np.float64_t[:, :] locs,
np.float64_t[:, :] cell_centers,
np.float64_t[:] mat_data,
ints[:] mat_indices,
ints[:] mat_indptr,
):
cdef:
ints i, j, diff, start, stop, i_d
ints n_max_per_row = 0
ints[:] close_cells
int dim = locs.shape[1]
np.float64_t[:, :] drs
np.float64_t[:] rs
np.float64_t[:] rhs
np.float64_t[:] lambs
np.float64_t[:] weights
np.float64_t[:] point
np.float64_t[:] close_cell
np.float64_t det, weight_sum
np.float64_t xx, xy, xz, yy, yz, zz
bint too_close
np.float64_t eps = 1E-15
# Find maximum number per row to pre-allocate a storage
for i in range(locs.shape[0]):
diff = mat_indptr[i+1] - mat_indptr[i]
if diff > n_max_per_row:
n_max_per_row = diff
#
drs = np.empty((n_max_per_row, dim), dtype=np.float64)
rs = np.empty((n_max_per_row,), dtype=np.float64)
rhs = np.empty((dim,),dtype=np.float64)
lambs = np.empty((dim,),dtype=np.float64)
for i in range(locs.shape[0]):
point = locs[i]
start = mat_indptr[i]
stop = mat_indptr[i+1]
diff = stop-start
close_cells = mat_indices[start:stop]
for j in range(diff):
rs[j] = 0.0
close_cell = cell_centers[close_cells[j]]
for i_d in range(dim):
drs[j, i_d] = close_cell[i_d] - point[i_d]
rs[j] += drs[j, i_d]*drs[j, i_d]
rs[j] = sqrt(rs[j])
weights = mat_data[start:stop]
weights[:] = 0.0
too_close = False
i_d = 0
for j in range(diff):
if rs[j] < eps:
too_close = True
i_d = j
if too_close:
weights[i_d] = 1.0
else:
for j in range(diff):
for i_d in range(dim):
drs[j, i_d] /= rs[j]
xx = xy = yy = 0.0
rhs[:] = 0.0
if dim == 2:
for j in range(diff):
xx += drs[j, 0] * drs[j, 0]
xy += drs[j, 0] * drs[j, 1]
yy += drs[j, 1] * drs[j, 1]
rhs[0] -= drs[j, 0]
rhs[1] -= drs[j, 1]
det = xx * yy - xy * xy
lambs[0] = (yy * rhs[0] - xy * rhs[1])/det
lambs[1] = (-xy * rhs[0] + xx * rhs[1])/det
if dim == 3:
zz = xz = yz = 0.0
for j in range(diff):
xx += drs[j, 0] * drs[j, 0]
xy += drs[j, 0] * drs[j, 1]
yy += drs[j, 1] * drs[j, 1]
xz += drs[j, 0] * drs[j, 2]
yz += drs[j, 1] * drs[j, 2]
zz += drs[j, 2] * drs[j, 2]
rhs[0] -= drs[j, 0]
rhs[1] -= drs[j, 1]
rhs[2] -= drs[j, 2]
det = (
xx * (yy * zz - yz * yz)
+ xy * (xz * yz - xy * zz)
+ xz * (xy * yz - xz * yy)
)
lambs[0] = (
(yy * zz - yz * yz) * rhs[0]
+ (xz * yz - xy * zz) * rhs[1]
+ (xy * yz - xz * yy) * rhs[2]
)/det
lambs[1] = (
(xz * yz - xy * zz) * rhs[0]
+ (xx * zz - xz * xz) * rhs[1]
+ (xy * xz - xx * yz) * rhs[2]
)/det
lambs[2] = (
(xy * yz - xz * yy) * rhs[0]
+ (xz * xy - xx * yz) * rhs[1]
+ (xx * yy - xy * xy) * rhs[2]
)/det
weight_sum = 0.0
for j in range(diff):
weights[j] = 1.0
for i_d in range(dim):
weights[j] += lambs[i_d] * drs[j, i_d]
weights[j] /= rs[j]
weight_sum += weights[j]
for j in range(diff):
weights[j] /= weight_sum
================================================
FILE: discretize/_extensions/tree.cpp
================================================
#include <vector>
#include <map>
#include "tree.h"
#include "geom.h"
#include <iostream>
#include <algorithm>
#include <limits>
Node::Node(){
location_ind[0] = 0;
location_ind[1] = 0;
location_ind[2] = 0;
location[0] = 0;
location[1] = 0;
location[2] = 0;
key = 0;
reference = 0;
index = 0;
hanging = false;
parents[0] = NULL;
parents[1] = NULL;
parents[2] = NULL;
parents[3] = NULL;
};
Node::Node(int_t ix, int_t iy, int_t iz, double* xs, double *ys, double *zs){
location_ind[0] = ix;
location_ind[1] = iy;
location_ind[2] = iz;
location[0] = xs[ix];
location[1] = ys[iy];
location[2] = zs[iz];
key = key_func(ix, iy, iz);
reference = 0;
index = 0;
hanging = false;
parents[0] = NULL;
parents[1] = NULL;
parents[2] = NULL;
parents[3] = NULL;
};
Edge::Edge(){
location_ind[0] = 0;
location_ind[1] = 0;
location_ind[2] = 0;
location[0] = 0;
location[1] = 0;
location[2] = 0;
key = 0;
index = 0;
reference = 0;
length = 0.0;
hanging = false;
points[0] = NULL;
points[1] = NULL;
parents[0] = NULL;
parents[1] = NULL;
};
Edge::Edge(Node& p1, Node& p2){
points[0] = &p1;
points[1] = &p2;
int_t ix, iy, iz;
ix = (p1.location_ind[0]+p2.location_ind[0])/2;
iy = (p1.location_ind[1]+p2.location_ind[1])/2;
iz = (p1.location_ind[2]+p2.location_ind[2])/2;
key = key_func(ix, iy, iz);
location_ind[0] = ix;
location_ind[1] = iy;
location_ind[2] = iz;
location[0] = (p1[0]+p2[0]) * 0.5;
location[1] = (p1[1]+p2[1]) * 0.5;
location[2] = (p1[2]+p2[2]) * 0.5;
length = (p2[0]-p1[0])
+ (p2[1]-p1[1])
+ (p2[2]-p1[2]);
reference = 0;
index = 0;
hanging = false;
parents[0] = NULL;
parents[1] = NULL;
}
Face::Face(){
location_ind[0] = 0;
location_ind[1] = 0;
location_ind[2] = 0;
location[0] = 0.0;
location[1] = 0.0;
location[2] = 0.0;
key = 0;
reference = 0;
index = 0;
area = 0;
hanging = false;
points[0] = NULL;
points[1] = NULL;
points[2] = NULL;
points[3] = NULL;
edges[0] = NULL;
edges[1] = NULL;
edges[2] = NULL;
edges[3] = NULL;
parent = NULL;
}
Face::Face(Node& p1, Node& p2, Node& p3, Node& p4){
points[0] = &p1;
points[1] = &p2;
points[2] = &p3;
points[3] = &p4;
int_t ix, iy, iz;
ix = (p1.location_ind[0]+p2.location_ind[0]+p3.location_ind[0]+p4.location_ind[0])/4;
iy = (p1.location_ind[1]+p2.location_ind[1]+p3.location_ind[1]+p4.location_ind[1])/4;
iz = (p1.location_ind[2]+p2.location_ind[2]+p3.location_ind[2]+p4.location_ind[2])/4;
key = key_func(ix, iy, iz);
location_ind[0] = ix;
location_ind[1] = iy;
location_ind[2] = iz;
location[0] = (p1[0]+p2[0]+p3[0]+p4[0]) * 0.25;
location[1] = (p1[1]+p2[1]+p3[1]+p4[1]) * 0.25;
location[2] = (p1[2]+p2[2]+p3[2]+p4[2]) * 0.25;
area = ((p2[0]-p1[0]) + (p2[1]-p1[1]) + (p2[2]-p1[2])) *
((p3[0]-p1[0]) + (p3[1]-p1[1]) + (p3[2]-p1[2]));
reference = 0;
index = 0;
hanging = false;
parent = NULL;
edges[0] = NULL;
edges[1] = NULL;
edges[2] = NULL;
edges[3] = NULL;
}
Node * set_default_node(node_map_t& nodes, int_t x, int_t y, int_t z,
double *xs, double *ys, double *zs){
int_t key = key_func(x, y, z);
auto [it, inserted] = nodes.try_emplace(key, nullptr);
if(inserted){
// construct a new item at the emplaced location
it->second = new Node(x, y, z, xs, ys, zs);
}
return it->second;
}
Edge * set_default_edge(edge_map_t& edges, Node& p1, Node& p2){
int_t xC = (p1.location_ind[0]+p2.location_ind[0])/2;
int_t yC = (p1.location_ind[1]+p2.location_ind[1])/2;
int_t zC = (p1.location_ind[2]+p2.location_ind[2])/2;
int_t key = key_func(xC, yC, zC);
auto [it, inserted] = edges.try_emplace(key, nullptr);
if(inserted){
// construct a new item at the emplaced location
it->second = new Edge(p1, p2);
}
return it->second;
};
Face * set_default_face(face_map_t& faces, Node& p1, Node& p2, Node& p3, Node& p4){
int_t x, y, z, key;
x = (p1.location_ind[0]+p2.location_ind[0]+p3.location_ind[0]+p4.location_ind[0])/4;
y = (p1.location_ind[1]+p2.location_ind[1]+p3.location_ind[1]+p4.location_ind[1])/4;
z = (p1.location_ind[2]+p2.location_ind[2]+p3.location_ind[2]+p4.location_ind[2])/4;
key = key_func(x, y, z);
auto [it, inserted] = faces.try_emplace(key, nullptr);
if(inserted){
// construct a new item at the emplaced location
it->second = new Face(p1, p2, p3, p4);
}
return it->second;
}
Cell::Cell(Node *pts[8], int_t ndim, int_t maxlevel){
n_dim = ndim;
int_t n_points = 1<<n_dim;
for(int_t i = 0; i < n_points; ++i)
points[i] = pts[i];
index = -1;
level = 0;
max_level = maxlevel;
parent = NULL;
Node p1 = *pts[0];
Node p2 = *pts[n_points - 1];
location_ind[0] = (p1.location_ind[0]+p2.location_ind[0])/2;
location_ind[1] = (p1.location_ind[1]+p2.location_ind[1])/2;
location_ind[2] = (p1.location_ind[2]+p2.location_ind[2])/2;
location[0] = (p1[0]+p2[0]) * 0.5;
location[1] = (p1[1]+p2[1]) * 0.5;
location[2] = (p1[2]+p2[2]) * 0.5;
volume = (p2[0]-p1[0]) * (p2[1]-p1[1]);
if(n_dim==3)
volume *= (p2[2] - p1[2]);
key = key_func(location_ind[0], location_ind[1], location_ind[2]);
for(int_t i = 0; i < n_points; ++i)
children[i] = NULL;
for(int_t i = 0; i < 2*n_dim; ++i)
neighbors[i] = NULL;
};
Cell::Cell(Node *pts[8], Cell *parent){
n_dim = parent->n_dim;
int_t n_points = 1<<n_dim;
for(int_t i = 0; i < n_points; ++i)
points[i] = pts[i];
index = -1;
level = parent->level + 1;
max_level = parent->max_level;
Node p1 = *pts[0];
Node p2 = *pts[n_points - 1];
location_ind[0] = (p1.location_ind[0]+p2.location_ind[0])/2;
location_ind[1] = (p1.location_ind[1]+p2.location_ind[1])/2;
location_ind[2] = (p1.location_ind[2]+p2.location_ind[2])/2;
location[0] = (p1[0]+p2[0]) * 0.5;
location[1] = (p1[1]+p2[1]) * 0.5;
location[2] = (p1[2]+p2[2]) * 0.5;
volume = (p2[0]-p1[0]) * (p2[1]-p1[1]);
if(n_dim == 3)
volume *= (p2[2] - p1[2]);
key = key_func(location_ind[0], location_ind[1], location_ind[2]);
for(int_t i = 0; i < n_points; ++i)
children[i] = NULL;
for(int_t i = 0; i < 2*n_dim; ++i)
neighbors[i] = NULL;
};
void Cell::spawn(node_map_t& nodes, Cell *kids[8], double *xs, double *ys, double *zs){
/* z0 z0+dz/2 z0+dz
p03--p13--p04 p20--p21--p22 p07--p27--p08
| | | | | | | | |
p10--p11--p12 p17--p18--p19 p24--p25--p26
| | | | | | | | |
p01--p09--p02 p14--p15--p16 p05--p23--p06
*/
Node *p1 = points[0];
Node *p2 = points[1];
Node *p3 = points[2];
Node *p4 = points[3];
int_t x0, y0, xC, yC, xF, yF, z0;
x0 = p1->location_ind[0];
y0 = p1->location_ind[1];
xF = p4->location_ind[0];
yF = p4->location_ind[1];
z0 = p1->location_ind[2];
xC = location_ind[0];
yC = location_ind[1];
Node *p9, *p10, *p11, *p12, *p13;
p9 = set_default_node(nodes, xC, y0, z0, xs, ys, zs);
p10 = set_default_node(nodes, x0, yC, z0, xs, ys, zs);
p11 = set_default_node(nodes, xC, yC, z0, xs, ys, zs);
p12 = set_default_node(nodes, xF, yC, z0, xs, ys, zs);
p13 = set_default_node(nodes, xC, yF, z0, xs, ys, zs);
//Increment node references for new nodes
p9->reference += 2;
p10->reference += 2;
p11->reference += 4;
p12->reference += 2;
p13->reference += 2;
if(n_dim>2){
Node *p5 = points[4];
Node *p6 = points[5];
Node *p7 = points[6];
Node *p8 = points[7];
int_t zC, zF;
zF = p8->location_ind[2];
zC = location_ind[2];
Node *p14, *p15, *p16, *p17, *p18, *p19, *p20, *p21, *p22;
Node *p23, *p24, *p25, *p26, *p27;
p14 = set_default_node(nodes, x0, y0, zC, xs, ys, zs);
p15 = set_default_node(nodes, xC, y0, zC, xs, ys, zs);
p16 = set_default_node(nodes, xF, y0, zC, xs, ys, zs);
p17 = set_default_node(nodes, x0, yC, zC, xs, ys, zs);
p18 = set_default_node(nodes, xC, yC, zC, xs, ys, zs);
p19 = set_default_node(nodes, xF, yC, zC, xs, ys, zs);
p20 = set_default_node(nodes, x0, yF, zC, xs, ys, zs);
p21 = set_default_node(nodes, xC, yF, zC, xs, ys, zs);
p22 = set_default_node(nodes, xF, yF, zC, xs, ys, zs);
p23 = set_default_node(nodes, xC, y0, zF, xs, ys, zs);
p24 = set_default_node(nodes, x0, yC, zF, xs, ys, zs);
p25 = set_default_node(nodes, xC, yC, zF, xs, ys, zs);
p26 = set_default_node(nodes, xF, yC, zF, xs, ys, zs);
p27 = set_default_node(nodes, xC, yF, zF, xs, ys, zs);
//Increment node references
p14->reference += 2;
p15->reference += 4;
p16->reference += 2;
p17->reference += 4;
p18->reference += 8;
p19->reference += 4;
p20->reference += 2;
p21->reference += 4;
p22->reference += 2;
p23->reference += 2;
p24->reference += 2;
p25->reference += 4;
p26->reference += 2;
p27->reference += 2;
Node * pQC1[8] = { p1, p9,p10,p11,p14,p15,p17,p18};
Node * pQC2[8] = { p9, p2,p11,p12,p15,p16,p18,p19};
Node * pQC3[8] = {p10,p11, p3,p13,p17,p18,p20,p21};
Node * pQC4[8] = {p11,p12,p13, p4,p18,p19,p21,p22};
Node * pQC5[8] = {p14,p15,p17,p18, p5,p23,p24,p25};
Node * pQC6[8] = {p15,p16,p18,p19,p23, p6,p25,p26};
Node * pQC7[8] = {p17,p18,p20,p21,p24,p25, p7,p27};
Node * pQC8[8] = {p18,p19,p21,p22,p25,p26,p27, p8};
kids[0] = new Cell(pQC1, this);
kids[1] = new Cell(pQC2, this);
kids[2] = new Cell(pQC3, this);
kids[3] = new Cell(pQC4, this);
kids[4] = new Cell(pQC5, this);
kids[5] = new Cell(pQC6, this);
kids[6] = new Cell(pQC7, this);
kids[7] = new Cell(pQC8, this);
}
else{
Node * pQC1[8] = { p1, p9,p10,p11, NULL, NULL, NULL, NULL};
Node * pQC2[8] = { p9, p2,p11,p12, NULL, NULL, NULL, NULL};
Node * pQC3[8] = {p10,p11, p3,p13, NULL, NULL, NULL, NULL};
Node * pQC4[8] = {p11,p12,p13, p4, NULL, NULL, NULL, NULL};
kids[0] = new Cell(pQC1, this);
kids[1] = new Cell(pQC2, this);
kids[2] = new Cell(pQC3, this);
kids[3] = new Cell(pQC4, this);
}
};
void Cell::set_neighbor(Cell * other, int_t position){
if(other==NULL){
return;
}
if(level != other->level){
neighbors[position] = other;
}else{
neighbors[position] = other;
other->neighbors[position^1] = this;
}
};
void Cell::shift_centers(double *shift){
for(int_t id = 0; id<n_dim; ++id){
location[id] += shift[id];
}
if(!is_leaf()){
for(int_t i = 0; i < (1<<n_dim); ++i){
children[i]->shift_centers(shift);
}
}
}
// intersections tests:
bool Cell::intersects_point(double *x){
// A simple bounding box check:
double *p0 = min_node()->location;
double *p1 = max_node()->location;
for(int_t i=0; i < n_dim; ++i){
if(x[i] < p0[i] || x[i] > p1[i]){
return false;
}
}
return true;
}
void Cell::insert_cell(node_map_t& nodes, double *new_cell, int_t p_level, double *xs, double *ys, double *zs, bool diag_balance){
//Inserts a cell at min(max_level,p_level) that contains the given point
if(p_level > level){
// Need to go look in children,
// Need to spawn children if i don't have any...
if(is_leaf()){
divide(nodes, xs, ys, zs, true, diag_balance);
}
int ix = new_cell[0] > children[0]->points[3]->location[0];
int iy = new_cell[1] > children[0]->points[3]->location[1];
int iz = n_dim>2 && new_cell[2]>children[0]->points[7]->location[2];
children[ix + 2*iy + 4*iz]->insert_cell(nodes, new_cell, p_level, xs, ys, zs, diag_balance);
}
};
void Cell::refine_func(node_map_t& nodes, function test_func, double *xs, double *ys, double *zs, bool diag_balance){
// return if I'm at the maximum level
if (level == max_level){
return;
}
if(is_leaf()){
// only evaluate the function on leaf cells
int test_level = (*test_func)(this);
if(test_level < 0){
test_level = (max_level + 1) - (abs(test_level) % (max_level + 1));
}
if (test_level <= level){
return;
}
divide(nodes, xs, ys, zs, true, diag_balance);
}
// should only be here if not a leaf cell, or I was divided by the function
// recurse into children
for(int_t i = 0; i < (1<<n_dim); ++i){
children[i]->refine_func(nodes, test_func, xs, ys, zs, diag_balance);
}
}
void Cell::refine_image(node_map_t& nodes, double* image, int_t *shape_cells, double *xs, double*ys, double *zs, bool diag_balance){
// early exit if my level is higher than or equal to target
if (level == max_level){
return;
}
int_t start_ix = points[0]->location_ind[0]/2;
int_t start_iy = points[0]->location_ind[1]/2;
int_t start_iz = n_dim == 2 ? 0 : points[0]->location_ind[2]/2;
int_t end_ix = points[3]->location_ind[0]/2;
int_t end_iy = points[3]->location_ind[1]/2;
int_t end_iz = n_dim == 2? 1 : points[7]->location_ind[2]/2;
int_t nx = shape_cells[0];
int_t ny = shape_cells[1];
int_t nz = shape_cells[2];
int_t i_image = (nx * ny) * start_iz + nx * start_iy + start_ix;
double val_start = image[i_image];
bool all_unique = true;
// if any of the image data contained in the cell are different, subdivide myself
for(int_t iz=start_iz; iz<end_iz && all_unique; ++iz)
for(int_t iy=start_iy; iy<end_iy && all_unique; ++iy)
for(int_t ix=start_ix; ix<end_ix && all_unique; ++ix){
i_image = (nx * ny) * iz + nx * iy + ix;
all_unique = image[i_image] == val_start;
}
if(!all_unique){
if(is_leaf()){
divide(nodes, xs, ys, zs, true, diag_balance);
}
// recurse into children
for(int_t i = 0; i < (1<<n_dim); ++i){
children[i]->refine_image(nodes, image, shape_cells, xs, ys, zs, diag_balance);
}
}
}
void Cell::divide(node_map_t& nodes, double* xs, double* ys, double* zs, bool balance, bool diag_balance){
// Gaurd against dividing a cell that is already at the max level
if (level == max_level){
return;
}
//If i haven't already been split...
if(is_leaf()){
spawn(nodes, children, xs, ys, zs);
//If I need to be split, and my neighbor is below my level
//Then it needs to be split
//-x,+x,-y,+y,-z,+z
if(balance){
for(int_t i = 0; i < 2*n_dim; ++i){
if(neighbors[i] != NULL && neighbors[i]->level < level){
neighbors[i]->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
}
if(diag_balance){
Cell *neighbor;
if (neighbors[0] != NULL){
// -x-y
if (neighbors[2] != NULL){
neighbor = neighbors[0]->neighbors[2];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
// -x+y
if (neighbors[3] != NULL){
neighbor = neighbors[0]->neighbors[3];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
}
if (neighbors[1] != NULL){
// +x-y
if (neighbors[2] != NULL){
neighbor = neighbors[1]->neighbors[2];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
// +x+y
if (neighbors[3] != NULL){
neighbor = neighbors[1]->neighbors[3];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
}
if(n_dim == 3){
// -z
if (neighbors[4] != NULL){
if (neighbors[0] != NULL){
// -z-x
neighbor = neighbors[4]->neighbors[0];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
// -z-x-y
if (neighbors[2] != NULL){
neighbor = neighbors[4]->neighbors[0]->neighbors[2];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
// -z-x+y
if (neighbors[3] != NULL){
neighbor = neighbors[4]->neighbors[0]->neighbors[3];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
}
if (neighbors[1] != NULL){
// -z+x
neighbor = neighbors[4]->neighbors[1];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
// -z+x-y
if (neighbors[2] != NULL){
neighbor = neighbors[4]->neighbors[1]->neighbors[2];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
// -z+x+y
if (neighbors[3] != NULL){
neighbor = neighbors[4]->neighbors[1]->neighbors[3];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
}
if (neighbors[2] != NULL){
// -z-y
neighbor = neighbors[4]->neighbors[2];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
if (neighbors[3] != NULL){
// -z+y
neighbor = neighbors[4]->neighbors[3];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
}
// +z
if (neighbors[5] != NULL){
if (neighbors[0] != NULL){
// +z-x
neighbor = neighbors[5]->neighbors[0];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
// +z-x-y
if (neighbors[2] != NULL){
neighbor = neighbors[5]->neighbors[0]->neighbors[2];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
// +z-x+y
if (neighbors[3] != NULL){
neighbor = neighbors[5]->neighbors[0]->neighbors[3];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
}
if (neighbors[1] != NULL){
// +z+x
neighbor = neighbors[5]->neighbors[1];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
// +z+x-y
if (neighbors[2] != NULL){
neighbor = neighbors[5]->neighbors[1]->neighbors[2];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
// +z+x+y
if (neighbors[3] != NULL){
neighbor = neighbors[5]->neighbors[1]->neighbors[3];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
}
if (neighbors[2] != NULL){
// +z-y
neighbor = neighbors[5]->neighbors[2];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
if (neighbors[3] != NULL){
// +z+y
neighbor = neighbors[5]->neighbors[3];
if(neighbor->level < level){
neighbor->divide(nodes, xs, ys, zs, balance, diag_balance);
}
}
}
}
}
//Set children's neighbors (first do the easy ones)
// all of the children live next to each other
children[0]->set_neighbor(children[1], 1);
children[0]->set_neighbor(children[2], 3);
children[1]->set_neighbor(children[3], 3);
children[2]->set_neighbor(children[3], 1);
if(n_dim == 3){
children[4]->set_neighbor(children[5], 1);
children[4]->set_neighbor(children[6], 3);
children[5]->set_neighbor(children[7], 3);
children[6]->set_neighbor(children[7], 1);
children[0]->set_neighbor(children[4], 5);
children[1]->set_neighbor(children[5], 5);
children[2]->set_neighbor(children[6], 5);
children[3]->set_neighbor(children[7], 5);
}
// -x direction
if(neighbors[0]!=NULL && !(neighbors[0]->is_leaf())){
children[0]->set_neighbor(neighbors[0]->children[1], 0);
children[2]->set_neighbor(neighbors[0]->children[3], 0);
}
else{
children[0]->set_neighbor(neighbors[0], 0);
children[2]->set_neighbor(neighbors[0], 0);
}
// +x direction
if(neighbors[1]!=NULL && !neighbors[1]->is_leaf()){
children[1]->set_neighbor(neighbors[1]->children[0], 1);
children[3]->set_neighbor(neighbors[1]->children[2], 1);
}else{
children[1]->set_neighbor(neighbors[1], 1);
children[3]->set_neighbor(neighbors[1], 1);
}
// -y direction
if(neighbors[2]!=NULL && !neighbors[2]->is_leaf()){
children[0]->set_neighbor(neighbors[2]->children[2], 2);
children[1]->set_neighbor(neighbors[2]->children[3], 2);
}else{
children[0]->set_neighbor(neighbors[2], 2);
children[1]->set_neighbor(neighbors[2], 2);
}
// +y direction
if(neighbors[3]!=NULL && !neighbors[3]->is_leaf()){
children[2]->set_neighbor(neighbors[3]->children[0], 3);
children[3]->set_neighbor(neighbors[3]->children[1], 3);
}else{
children[2]->set_neighbor(neighbors[3], 3);
children[3]->set_neighbor(neighbors[3], 3);
}
if(n_dim==3){
// -x direction
if(neighbors[0]!=NULL && !(neighbors[0]->is_leaf())){
children[4]->set_neighbor(neighbors[0]->children[5], 0);
children[6]->set_neighbor(neighbors[0]->children[7], 0);
}
else{
children[4]->set_neighbor(neighbors[0], 0);
children[6]->set_neighbor(neighbors[0], 0);
}
// +x direction
if(neighbors[1]!=NULL && !neighbors[1]->is_leaf()){
children[5]->set_neighbor(neighbors[1]->children[4], 1);
children[7]->set_neighbor(neighbors[1]->children[6], 1);
}else{
children[5]->set_neighbor(neighbors[1], 1);
children[7]->set_neighbor(neighbors[1], 1);
}
// -y direction
if(neighbors[2]!=NULL && !neighbors[2]->is_leaf()){
children[4]->set_neighbor(neighbors[2]->children[6], 2);
children[5]->set_neighbor(neighbors[2]->children[7], 2);
}else{
children[4]->set_neighbor(neighbors[2], 2);
children[5]->set_neighbor(neighbors[2], 2);
}
// +y direction
if(neighbors[3]!=NULL && !neighbors[3]->is_leaf()){
children[6]->set_neighbor(neighbors[3]->children[4], 3);
children[7]->set_neighbor(neighbors[3]->children[5], 3);
}else{
children[6]->set_neighbor(neighbors[3], 3);
children[7]->set_neighbor(neighbors[3], 3);
}
// -z direction
if(neighbors[4]!=NULL && !neighbors[4]->is_leaf()){
children[0]->set_neighbor(neighbors[4]->children[4], 4);
children[1]->set_neighbor(neighbors[4]->children[5], 4);
children[2]->set_neighbor(neighbors[4]->children[6], 4);
children[3]->set_neighbor(neighbors[4]->children[7], 4);
}else{
children[0]->set_neighbor(neighbors[4], 4);
children[1]->set_neighbor(neighbors[4], 4);
children[2]->set_neighbor(neighbors[4], 4);
children[3]->set_neighbor(neighbors[4], 4);
}
// +z direction
if(neighbors[5]!=NULL && !neighbors[5]->is_leaf()){
children[4]->set_neighbor(neighbors[5]->children[0], 5);
children[5]->set_neighbor(neighbors[5]->children[1], 5);
children[6]->set_neighbor(neighbors[5]->children[2], 5);
children[7]->set_neighbor(neighbors[5]->children[3], 5);
}else{
children[4]->set_neighbor(neighbors[5], 5);
children[5]->set_neighbor(neighbors[5], 5);
children[6]->set_neighbor(neighbors[5], 5);
children[7]->set_neighbor(neighbors[5], 5);
}
}
}
};
void Cell::build_cell_vector(cell_vec_t& cells){
if(this->is_leaf()){
cells.push_back(this);
return;
}
for(int_t i = 0; i < (1<<n_dim); ++i){
children[i]->build_cell_vector(cells);
}
}
Cell* Cell::containing_cell(double x, double y, double z){
if(is_leaf()){
return this;
}
int ix = x > children[0]->points[3]->location[0];
int iy = y > children[0]->points[3]->location[1];
int iz = n_dim>2 && z>children[0]->points[7]->location[2];
return children[ix + 2*iy + 4*iz]->containing_cell(x, y, z);
};
Cell::~Cell(){
if(is_leaf()){
return;
}
for(int_t i = 0; i< (1<<n_dim); ++i){
delete children[i];
}
};
Tree::Tree(){
nx = 0;
ny = 0;
nz = 0;
n_dim = 0;
max_level = 0;
};
void Tree::set_dimension(int_t dim){
n_dim = dim;
}
void Tree::set_levels(int_t l_x, int_t l_y, int_t l_z){
int_t min_l = std::min(l_x, l_y);
if(n_dim == 3) min_l = std::min(min_l, l_z);
max_level = min_l;
if(l_x != l_y || (n_dim==3 && l_y!=l_z)) ++max_level;
nx = 2<<l_x;
ny = 2<<l_y;
nz = (n_dim == 3)? 2<<l_z : 0;
nx_roots = 1<<(l_x-(max_level-1));
ny_roots = 1<<(l_y-(max_level-1));
nz_roots = (n_dim==3)? 1<<(l_z-(max_level-1)) : 1;
if (l_x==l_y && (n_dim==2 || l_y==l_z)){
--nx_roots;
--ny_roots;
--nz_roots;
}
ixs = new int_t[nx_roots+1];
iys = new int_t[ny_roots+1];
izs = new int_t[nz_roots+1];
int_t min_n = 2<<min_l;
for(int_t i=0; i<nx_roots+1; ++i){
ixs[i] = min_n*i;
}
for(int_t i=0; i<ny_roots+1; ++i){
iys[i] = min_n*i;
}
for(int_t i=0; i<nz_roots+1; ++i){
izs[i] = min_n*i;
}
if(n_dim == 2) nz_roots = 1;
// Initialize root cell container
roots.resize(nz_roots);
for(int_t iz=0; iz<nz_roots; ++iz){
roots[iz].resize(ny_roots);
for(int_t iy=0; iy<ny_roots; ++iy){
roots[iz][iy].resize(nx_roots);
for(int_t ix=0; ix<nx_roots; ++ix){
roots[iz][iy][ix] = NULL;
}
}
}
};
void Tree::set_xs(double *x, double *y, double *z){
xs = x;
ys = y;
zs = z;
}
void Tree::initialize_roots(){
if(roots[0][0][0]==NULL){
//Create grid of root nodes
std::vector<std::vector<std::vector<Node *> > > points;
if(n_dim == 2){
points.resize(1);
}else{
points.resize(nz_roots+1);
}
for(int_t iz = 0; iz<points.size(); ++iz){
points[iz].resize(ny_roots+1);
for(int_t iy = 0; iy<ny_roots+1; ++iy){
points[iz][iy].resize(nx_roots+1);
for(int_t ix = 0; ix<nx_roots+1; ++ix){
points[iz][iy][ix] = new Node(ixs[ix], iys[iy], izs[iz],
xs, ys, zs);
nodes[points[iz][iy][ix]->key] = points[iz][iy][ix];
}
}
}
// Create grid of root cells
for (int_t iz = 0; iz<nz_roots; ++iz){
for (int_t iy = 0; iy<ny_roots; ++iy){
for (int_t ix = 0; ix<nx_roots; ++ix){
Node *ps[8];
ps[0] = points[iz][iy ][ix ];
ps[1] = points[iz][iy ][ix+1];
ps[2] = points[iz][iy+1][ix ];
ps[3] = points[iz][iy+1][ix+1];
if (n_dim == 3){
ps[4] = points[iz+1][iy ][ix ];
ps[5] = points[iz+1][iy ][ix+1];
ps[6] = points[iz+1][iy+1][ix ];
ps[7] = points[iz+1][iy+1][ix+1];
}
roots[iz][iy][ix] = new Cell(ps, n_dim, max_level);
if (nx==ny && (n_dim==2 || ny==nz)){
roots[iz][iy][ix]->level = 0;
}else{
roots[iz][iy][ix]->level = 1;
}
for(int_t i = 0; i < (1<<n_dim); ++i){
ps[i]->reference += 1;
}
}
}
}
// Set root cell neighbors
// +x neighbors
for(int_t iz=0; iz<nz_roots; ++iz)
for (int_t iy=0; iy<ny_roots; ++iy)
for(int_t ix=0; ix<nx_roots-1; ++ix)
roots[iz][iy][ix]->set_neighbor(roots[iz][iy][ix+1], 1);
// +y neighbors
for(int_t iz=0; iz<nz_roots; ++iz)
for(int_t iy=0; iy<ny_roots-1; ++iy)
for(int_t ix=0; ix<nx_roots; ++ix)
roots[iz][iy][ix]->set_neighbor(roots[iz][iy+1][ix], 3);
// +z neighbors
for(int_t iz=0; iz<nz_roots-1; ++iz)
for(int_t iy=0; iy<ny_roots; ++iy)
for(int_t ix=0; ix<nx_roots; ++ix)
roots[iz][iy][ix]->set_neighbor(roots[iz+1][iy][ix], 5);
}
}
void Tree::insert_cell(double *new_center, int_t p_level, bool diagonal_balance){
// find containing root
int_t ix = 0;
int_t iy = 0;
int_t iz = 0;
while (new_center[0]>=xs[ixs[ix+1]] && ix<nx_roots-1){
++ix;
}
while (new_center[1]>=ys[iys[iy+1]] && iy<ny_roots-1){
++iy;
}
if(n_dim == 3){
while(new_center[2]>=zs[izs[iz+1]] && iz<nz_roots-1){
++iz;
}
}
roots[iz][iy][ix]->insert_cell(nodes, new_center, p_level, xs, ys, zs, diagonal_balance);
}
void Tree::refine_function(function test_func, bool diagonal_balance){
//Now we can divide
for(int_t iz=0; iz<nz_roots; ++iz)
for(int_t iy=0; iy<ny_roots; ++iy)
for(int_t ix=0; ix<nx_roots; ++ix)
roots[iz][iy][ix]->refine_func(nodes, test_func, xs, ys, zs, diagonal_balance);
};
void Tree::refine_image(double *image, bool diagonal_balance){
int_t shape_cells[3];
shape_cells[0] = nx/2;
shape_cells[1] = ny/2;
shape_cells[2] = nz/2;
for(int_t iz=0; iz<nz_roots; ++iz)
for(int_t iy=0; iy<ny_roots; ++iy)
for(int_t ix=0; ix<nx_roots; ++ix)
roots[iz][iy][ix]->refine_image(nodes, image, shape_cells, xs, ys, zs, diagonal_balance);
}
void Tree::finalize_lists(){
for(int_t iz=0; iz<nz_roots; ++iz)
for(int_t iy=0; iy<ny_roots; ++iy)
for(int_t ix=0; ix<nx_roots; ++ix)
roots[iz][iy][ix]->build_cell_vector(cells);
if(n_dim == 3){
// Generate Faces and edges
for(std::vector<Cell *>::size_type i = 0; i != cells.size(); i++){
Cell *cell = cells[i];
Node *p[8];
for(int_t it = 0; it < 8; ++it)
p[it] = cell->points[it];
Edge *ex[4];
Edge *ey[4];
Edge *ez[4];
ex[0] = set_default_edge(edges_x, *p[0], *p[1]);
ex[1] = set_default_edge(edges_x, *p[2], *p[3]);
ex[2] = set_default_edge(edges_x, *p[4], *p[5]);
ex[3] = set_default_edge(edges_x, *p[6], *p[7]);
ey[0] = set_default_edge(edges_y, *p[0], *p[2]);
ey[1] = set_default_edge(edges_y, *p[1], *p[3]);
ey[2] = set_default_edge(edges_y, *p[4], *p[6]);
ey[3] = set_default_edge(edges_y, *p[5], *p[7]);
ez[0] = set_default_edge(edges_z, *p[0], *p[4]);
ez[1] = set_default_edge(edges_z, *p[1], *p[5]);
ez[2] = set_default_edge(edges_z, *p[2], *p[6]);
ez[3] = set_default_edge(edges_z, *p[3], *p[7]);
Face *fx1, *fx2, *fy1, *fy2, *fz1, *fz2;
fx1 = set_default_face(faces_x, *p[0], *p[2], *p[4], *p[6]);
fx2 = set_default_face(faces_x, *p[1], *p[3], *p[5], *p[7]);
fy1 = set_default_face(faces_y, *p[0], *p[1], *p[4], *p[5]);
fy2 = set_default_face(faces_y, *p[2], *p[3], *p[6], *p[7]);
fz1 = set_default_face(faces_z, *p[0], *p[1], *p[2], *p[3]);
fz2 = set_default_face(faces_z, *p[4], *p[5], *p[6], *p[7]);
fx1->edges[0] = ez[0];
fx1->edges[1] = ey[2];
fx1->edges[2] = ez[2];
fx1->edges[3] = ey[0];
fx2->edges[0] = ez[1];
fx2->edges[1] = ey[3];
fx2->edges[2] = ez[3];
fx2->edges[3] = ey[1];
fy1->edges[0] = ez[0];
fy1->edges[1] = ex[2];
fy1->edges[2] = ez[1];
fy1->edges[3] = ex[0];
fy2->edges[0] = ez[2];
fy2->edges[1] = ex[3];
fy2->edges[2] = ez[3];
fy2->edges[3] = ex[1];
fz1->edges[0] = ey[0];
fz1->edges[1] = ex[1];
fz1->edges[2] = ey[1];
fz1->edges[3] = ex[0];
fz2->edges[0] = ey[2];
fz2->edges[1] = ex[3];
fz2->edges[2] = ey[3];
fz2->edges[3] = ex[2];
cell->faces[0] = fx1;
cell->faces[1] = fx2;
cell->faces[2] = fy1;
cell->faces[3] = fy2;
cell->faces[4] = fz1;
cell->faces[5] = fz2;
for(int_t it = 0; it < 4; ++it){
cell->edges[it ] = ex[it];
cell->edges[it + 4] = ey[it];
cell->edges[it + 8] = ez[it];
}
for(int_t it = 0; it < 6; ++it)
cell->faces[it]->reference++;
for(int_t it = 0; it < 12; ++it)
cell->edges[it]->reference++;
}
// Process hanging x faces
for(face_it_type it = faces_x.begin(); it != faces_x.end(); ++it){
Face *face = it->second;
if(face->reference < 2){
int_t x;
x = face->location_ind[0];
if(x==0 || x==nx) continue; // Face was on the outside, and is not hanging
if(nodes.count(face->key)) continue; // I will have children (there is a node at my center)
Node *node;
//Find Parent
int_t ip;
for(int_t i = 0; i < 4; ++i){
node = face->points[i];
ip = i;
if(faces_x.count(node->key)){
face->parent = faces_x[node->key];
break;
}
}
//all of my edges are hanging, and most of my points
for(int_t i = 0; i < 4; ++i){
face->edges[i]->hanging = true;
face->points[i]->hanging = true;
}
// the point oposite the parent node key should not be hanging
// and also label the edges' parents
if(face->points[ip^3]->reference != 6)
face->points[ip^3]->hanging = false;
face->edges[0]->parents[0] = face->parent->edges[0];
face->edges[0]->parents[1] = face->parent->edges[((ip&1)^1)<<1]; //2020
face->edges[1]->parents[0] = face->parent->edges[1];
face->edges[1]->parents[1] = face->parent->edges[ip>>1<<1^1]; //1133
face->edges[2]->parents[0] = face->parent->edges[((ip&1)^1)<<1]; //2020
face->edges[2]->parents[1] = face->parent->edges[2];
face->edges[3]->parents[0] = face->parent->edges[ip>>1<<1^1]; //1133
face->edges[3]->parents[1] = face->parent->edges[3];
face->points[ip^1]->parents[0] = face->parent->points[(ip&1)^1]; //1010
face->points[ip^1]->parents[1] = face->parent->points[(ip&1)^3]; //3232
face->points[ip^1]->parents[2] = face->parent->points[(ip&1)^1]; //1010
face->points[ip^1]->parents[3] = face->parent->points[(ip&1)^3]; //3232
face->points[ip^2]->parents[0] = face->parent->points[(ip>>1^1)<<1]; //2200
face->points[ip^2]->parents[1] = face->parent->points[(ip>>1^1)<<1^1]; //3311
face->points[ip^2]->parents[2] = face->parent->points[(ip>>1^1)<<1]; //2200
face->points[ip^2]->parents[3] = face->parent->points[(ip>>1^1)<<1^1]; //3311
face->hanging = true;
hanging_faces_x.push_back(face);
for(int_t i = 0; i < 4; ++i)
node->parents[i] = face->parent->points[i];
}
}
// Process hanging y faces
for(face_it_type it = faces_y.begin(); it != faces_y.end(); ++it){
Face *face = it->second;
if(face->reference < 2){
int_t y;
y = face->location_ind[1];
if(y==0 || y==ny) continue; // Face was on the outside, and is not hanging
if(nodes.count(face->key)) continue; // I will have children (there is a node at my center)
Node *node;
//Find Parent
int_t ip;
for(int_t i = 0; i < 4; ++i){
node = face->points[i];
ip = i;
if(faces_y.count(node->key)){
face->parent = faces_y[node->key];
break;
}
}
//all of my edges are hanging, and most of my points
for(int_t i = 0; i < 4; ++i){
face->edges[i]->hanging = true;
face->points[i]->hanging = true;
}
// the point oposite the parent node key should not be hanging
// and also label the edges' parents
if(face->points[ip^3]->reference != 6)
face->points[ip^3]->hanging = false;
face->edges[0]->parents[0] = face->parent->edges[0];
face->edges[0]->parents[1] = face->parent->edges[((ip&1)^1)<<1]; //2020
face->edges[1]->parents[0] = face->parent->edges[1];
face->edges[1]->parents[1] = face->parent->edges[ip>>1<<1^1]; //1133
face->edges[2]->parents[0] = face->parent->edges[((ip&1)^1)<<1]; //2020
face->edges[2]->parents[1] = face->parent->edges[2];
face->edges[3]->parents[0] = face->parent->edges[ip>>1<<1^1]; //1133
face->edges[3]->parents[1] = face->parent->edges[3];
face->points[ip^1]->parents[0] = face->parent->points[(ip&1)^1]; //1010
face->points[ip^1]->parents[1] = face->parent->points[(ip&1)^3]; //3232
face->points[ip^1]->parents[2] = face->parent->points[(ip&1)^1]; //1010
face->points[ip^1]->parents[3] = face->parent->points[(ip&1)^3]; //3232
face->points[ip^2]->parents[0] = face->parent->points[(ip>>1^1)<<1]; //2200
face->points[ip^2]->parents[1] = face->parent->points[(ip>>1^1)<<1^1]; //3311
face->points[ip^2]->parents[2] = face->parent->points[(ip>>1^1)<<1]; //2200
face->points[ip^2]->parents[3] = face->parent->points[(ip>>1^1)<<1^1]; //3311
face->hanging = true;
hanging_faces_y.push_back(face);
for(int_t i = 0; i < 4; ++i){
node->parents[i] = face->parent->points[i];
}
}
}
// Process hanging z faces
for(face_it_type it = faces_z.begin(); it != faces_z.end(); ++it){
Face *face = it->second;
if(face->reference < 2){
int_t z;
z = face->location_ind[2];
if(z==0 || z==nz){
// Face was on the outside, and is not hanging
continue;
}
//check if I am a parent or a child
if(nodes.count(face->key)){
// I will have children (there is a node at my center)
continue;
}
Node *node;
//Find Parent
int_t ip;
for(int_t i = 0; i < 4; ++i){
node = face->points[i];
ip = i;
if(faces_z.count(node->key)){
face->parent = faces_z[node->key];
ip = i;
break;
}
}
//all of my edges are hanging, and most of my points
for(int_t i = 0; i < 4; ++i){
face->edges[i]->hanging = true;
face->points[i]->hanging = true;
}
// the point oposite the parent node key should not be hanging
// most of the time
// and also label the edges' parents
if(face->points[ip^3]->reference != 6)
face->points[ip^3]->hanging = false;
face->edges[0]->parents[0] = face->parent->edges[0];
face->edges[0]->parents[1] = face->parent->edges[((ip&1)^1)<<1]; //2020
face->edges[1]->parents[0] = face->parent->edges[1];
face->edges[1]->parents[1] = face->parent->edges[ip>>1<<1^1]; //1133
face->edges[2]->parents[0] = face->parent->edges[((ip&1)^1)<<1]; //2020
face->edges[2]->parents[1] = face->parent->edges[2];
face->edges[3]->parents[0] = face->parent->edges[ip>>1<<1^1]; //1133
face->edges[3]->parents[1] = face->parent->edges[3];
face->points[ip^1]->parents[0] = face->parent->points[(ip&1)^1]; //1010
face->points[ip^1]->parents[1] = face->parent->points[(ip&1)^3]; //3232
face->points[ip^1]->parents[2] = face->parent->points[(ip&1)^1]; //1010
face->points[ip^1]->parents[3] = face->parent->points[(ip&1)^3]; //3232
face->points[ip^2]->parents[0] = face->parent->points[(ip>>1^1)<<1]; //2200
face->points[ip^2]->parents[1] = face->parent->points[(ip>>1^1)<<1^1]; //3311
face->points[ip^2]->parents[2] = face->parent->points[(ip>>1^1)<<1]; //2200
face->points[ip^2]->parents[3] = face->parent->points[(ip>>1^1)<<1^1]; //3311
face->hanging = true;
hanging_faces_z.push_back(face);
for(int_t i = 0; i < 4; ++i){
node->parents[i] = face->parent->points[i];
}
}
}
}
else{
//Generate Edges (and 1 face for consistency)
for(std::vector<Cell *>::size_type i=0; i != cells.size(); i++){
Cell *cell = cells[i];
Node *p[4];
for(int_t i = 0; i < 4; ++i)
p[i] = cell->points[i];
Edge *e[4];
e[0] = set_default_edge(edges_x, *p[0], *p[1]);
e[1] = set_default_edge(edges_x, *p[2], *p[3]);
e[2] = set_default_edge(edges_y, *p[0], *p[2]);
e[3] = set_default_edge(edges_y, *p[1], *p[3]);
Face *face = set_default_face(faces_z, *p[0], *p[1], *p[2], *p[3]);
cell->edges[0] = e[0]; // -x
cell->edges[1] = e[1]; // +x
cell->edges[2] = e[2]; // -y
cell->edges[3] = e[3]; // +y
// number these clockwise from x0,y0
face->edges[0] = e[2]; // -y
face->edges[1] = e[1]; // +x
face->edges[2] = e[3]; // +y
face->edges[3] = e[0]; // -x
for(int_t i = 0; i < 4; ++i){
e[i]->reference++;
}
face->hanging=false;
}
//Process hanging x edges
for(edge_it_type it = edges_x.begin(); it != edges_x.end(); ++it){
Edge *edge = it->second;
if(edge->reference < 2){
int_t y = edge->location_ind[1];
if(y==0 || y==ny) continue; //I am on the boundary
if(nodes.count(edge->key)) continue; //I am a parent
//I am a hanging edge find my parent
Node *node;
if(edges_x.count(edge->points[0]->key)){
node = edge->points[0];
}else{
node = edge->points[1];
}
edge->parents[0] = edges_x[node->key];
edge->parents[1] = edge->parents[0];
node->hanging = true;
for(int_t i = 0; i<4; ++i)
node->parents[i] = edge->parents[0]->points[i%2];
edge->hanging = true;
}
}
//Process hanging y edges
for(edge_it_type it = edges_y.begin(); it != edges_y.end(); ++it){
Edge *edge = it->second;
if(edge->reference < 2){
int_t x = edge->location_ind[0];
if(x==0 || x==nx) continue; //I am on the boundary
if(nodes.count(edge->key)) continue; //I am a parent
//I am a hanging edge find my parent
Node *node;
if(edges_y.count(edge->points[0]->key)){
node = edge->points[0];
}else{
node = edge->points[1];
}
edge->parents[0] = edges_y[node->key];
edge->parents[1] = edge->parents[0];
node->hanging = true;
for(int_t i = 0; i < 4; ++i)
node->parents[i] = edge->parents[0]->points[i%2];
edge->hanging = true;
}
}
}
//List hanging edges x
for(edge_it_type it = edges_x.begin(); it != edges_x.end(); ++it){
Edge *edge = it->second;
if(edge->hanging){
hanging_edges_x.push_back(edge);
}
}
//List hanging edges y
for(edge_it_type it = edges_y.begin(); it != edges_y.end(); ++it){
Edge *edge = it->second;
if(edge->hanging){
hanging_edges_y.push_back(edge);
}
}
if(n_dim==3){
//List hanging edges z
for(edge_it_type it = edges_z.begin(); it != edges_z.end(); ++it){
Edge *edge = it->second;
if(edge->hanging){
hanging_edges_z.push_back(edge);
}
}
}
//List hanging nodes
for(node_it_type it = nodes.begin(); it != nodes.end(); ++it){
Node *node = it->second;
if(node->hanging){
hanging_nodes.push_back(node);
}
}
}
void Tree::number(){
//Number Nodes
int_t ii, ih;
ii = 0;
ih = nodes.size() - hanging_nodes.size();
for(node_it_type it = nodes.begin(); it != nodes.end(); ++it){
Node *node = it->second;
if(node->hanging){
node->index = ih;
++ih;
}else{
node->index = ii;
++ii;
}
}
//Number Cells
for(std::vector<Cell *>::size_type i = 0; i != cells.size(); ++i)
cells[i]->index = i;
//Number edges_x
ii = 0;
ih = edges_x.size() - hanging_edges_x.size();
for(edge_it_type it = edges_x.begin(); it != edges_x.end(); ++it){
Edge *edge = it->second;
if(edge->hanging){
edge->index = ih;
++ih;
}else{
edge->index = ii;
++ii;
}
}
//Number edges_y
ii = 0;
ih = edges_y.size() - hanging_edges_y.size();
for(edge_it_type it = edges_y.begin(); it != edges_y.end(); ++it){
Edge *edge = it->second;
if(edge->hanging){
edge->index = ih;
++ih;
}else{
edge->index = ii;
++ii;
}
}
if(n_dim==3){
//Number faces_x
ii = 0;
ih = faces_x.size() - hanging_faces_x.size();
for(face_it_type it = faces_x.begin(); it != faces_x.end(); ++it){
Face *face = it->second;
if(face->hanging){
face->index = ih;
++ih;
}else{
face->index = ii;
++ii;
}
}
//Number faces_y
ii = 0;
ih = faces_y.size() - hanging_faces_y.size();
for(face_it_type it = faces_y.begin(); it != faces_y.end(); ++it){
Face *face = it->second;
if(face->hanging){
face->index = ih;
++ih;
}else{
face->index = ii;
++ii;
}
}
//Number faces_z
ii = 0;
ih = faces_z.size() - hanging_faces_z.size();
for(face_it_type it = faces_z.begin(); it != faces_z.end(); ++it){
Face *face = it->second;
if(face->hanging){
face->index = ih;
++ih;
}else{
face->index = ii;
++ii;
}
}
//Number edges_z
ii = 0;
ih = edges_z.size() - hanging_edges_z.size();
for(edge_it_type it = edges_z.begin(); it != edges_z.end(); ++it){
Edge *edge = it->second;
if(edge->hanging){
edge->index = ih;
++ih;
}else{
edge->index = ii;
++ii;
}
}
}else{
//Ensure Fz and cells are numbered the same in 2D
for(std::vector<Cell *>::size_type i = 0; i != cells.size(); ++i)
faces_z[cells[i]->key]->index = cells[i]->index;
}
};
Tree::~Tree(){
if (roots.size() == 0){
return;
}
for(int_t iz=0; iz<nz_roots; ++iz){
for(int_t iy=0; iy<ny_roots; ++iy){
for(int_t ix=0; ix<nx_roots; ++ix){
delete roots[iz][iy][ix];
}
}
}
delete[] ixs;
delete[] iys;
delete[] izs;
for(node_it_type it = nodes.begin(); it != nodes.end(); ++it){
delete it->second;
}
for(face_it_type it = faces_x.begin(); it != faces_x.end(); ++it){
delete it->second;
}
for(face_it_type it = faces_y.begin(); it != faces_y.end(); ++it){
delete it->second;
}
for(face_it_type it = faces_z.begin(); it != faces_z.end(); ++it){
delete it->second;
}
for(edge_it_type it = edges_x.begin(); it != edges_x.end(); ++it){
delete it->second;
}
for(edge_it_type it = edges_y.begin(); it != edges_y.end(); ++it){
delete it->second;
}
for(edge_it_type it = edges_z.begin(); it != edges_z.end(); ++it){
delete it->second;
}
roots.clear();
cells.clear();
nodes.clear();
faces_x.clear();
faces_y.clear();
faces_z.clear();
edges_x.clear();
edges_y.clear();
edges_z.clear();
};
Cell* Tree::containing_cell(double x, double y, double z){
// find containing root
int_t ix = 0;
int_t iy = 0;
int_t iz = 0;
while (x>=xs[ixs[ix+1]] && ix<nx_roots-1){
++ix;
}
while (y>=ys[iys[iy+1]] && iy<ny_roots-1){
++iy;
}
if(n_dim == 3){
while(z>=zs[izs[iz+1]] && iz<nz_roots-1){
++iz;
}
}
return roots[iz][iy][ix]->containing_cell(x, y, z);
}
void Tree::shift_cell_centers(double *shift){
for(int_t iz=0; iz<nz_roots; ++iz)
for(int_t iy=0; iy<ny_roots; ++iy)
for(int_t ix=0; ix<nx_roots; ++ix)
roots[iz][iy][ix]->shift_centers(shift);
}
================================================
FILE: discretize/_extensions/tree.h
================================================
#ifndef __TREE_H
#define __TREE_H
#include <vector>
#include <map>
#include <iostream>
#include <algorithm>
#include "geom.h"
typedef std::size_t int_t;
inline int_t key_func(int_t x, int_t y){
//Double Cantor pairing
return ((x+y)*(x+y+1))/2+y;
}
inline int_t key_func(int_t x, int_t y, int_t z){
return key_func(key_func(x, y), z);
}
class Node;
class Edge;
class Face;
class Cell;
class Tree;
class PyWrapper;
typedef PyWrapper* function;
typedef std::map<int_t, Node *> node_map_t;
typedef std::map<int_t, Edge *> edge_map_t;
typedef std::map<int_t, Face *> face_map_t;
typedef node_map_t::iterator node_it_type;
typedef edge_map_t::iterator edge_it_type;
typedef face_map_t::iterator face_it_type;
typedef std::vector<Cell *> cell_vec_t;
typedef std::vector<int_t> int_vec_t;
class PyWrapper{
public:
void *py_func;
int (*eval)(void *, Cell*);
PyWrapper(){
py_func = NULL;
};
void set(void* func, int (*wrapper)(void*, Cell*)){
py_func = func;
eval = wrapper;
};
int operator()(Cell * cell){
return eval(py_func, cell);
};
};
class Node{
public:
int_t location_ind[3];
double location[3];
int_t key;
int_t reference;
int_t index;
bool hanging;
Node *parents[4];
Node();
Node(int_t, int_t, int_t, double*, double*, double*);
double operator[](int_t index){
return location[index];
};
};
class Edge{
public:
int_t location_ind[3];
double location[3];
int_t key;
int_t reference;
int_t index;
double length;
bool hanging;
Node *points[2];
Edge *parents[2];
Edge();
Edge(Node& p1, Node&p2);
double operator[](int_t index){
return location[index];
};
};
class Face{
public:
int_t location_ind[3];
double location[3];
int_t key;
int_t reference;
int_t index;
double area;
bool hanging;
Node *points[4];
Edge *edges[4];
Face *parent;
Face();
Face(Node& p1, Node& p2, Node& p3, Node& p4);
double operator[](int_t index){
return location[index];
};
};
class Cell{
public:
int_t n_dim;
Cell *parent, *children[8], *neighbors[6];
Node *points[8];
Edge *edges[12];
Face *faces[6];
int_t location_ind[3], key, level, max_level;
long long int index; // non root parents will have a -1 value
double location[3];
double operator[](int_t index){
return location[index];
};
double volume;
Cell();
Cell(Node *pts[8], int_t ndim, int_t maxlevel);//, function func);
Cell(Node *pts[8], Cell *parent);
~Cell();
inline Node* min_node(){ return points[0];};
inline Node* max_node(){ return points[(1<<n_dim)-1];};
// intersection tests
bool intersects_point(double *x);
Cell* containing_cell(double, double, double);
void insert_cell(node_map_t &nodes, double *new_center, int_t p_level, double* xs, double *ys, double *zs, bool diag_balance=false);
void refine_func(node_map_t& nodes, function test_func, double *xs, double *ys, double* zs, bool diag_balance=false);
void refine_image(node_map_t& nodes, double* image, int_t *shape_cells, double *xs, double*ys, double *zs, bool diagonal_balance=false);
inline bool is_leaf(){ return children[0]==NULL;};
void spawn(node_map_t& nodes, Cell *kids[8], double* xs, double *ys, double *zs);
void divide(node_map_t& nodes, double* xs, double* ys, double* zs, bool balance=true, bool diag_balance=false);
void set_neighbor(Cell* other, int_t direction);
void build_cell_vector(cell_vec_t& cells);
void shift_centers(double * shift);
template <class T>
void refine_geom(node_map_t& nodes, const T& geom, int_t p_level, double *xs, double *ys, double* zs, bool diag_balance=false){
// early exit if my level is higher than or equal to target
if (level >= p_level || level == max_level){
return;
}
double *a = min_node()->location;
double *b = max_node()->location;
// if I intersect cell, I will need to be divided (if I'm not already)
if (geom.intersects_cell(a, b)){
if(is_leaf()){
divide(nodes, xs, ys, zs, true, diag_balance);
}
// recurse into children
for(int_t i = 0; i < (1<<n_dim); ++i){
children[i]->refine_geom(nodes, geom, p_level, xs, ys, zs, diag_balance);
}
}
}
template <class T>
void find_cells_geom(int_vec_t &cells, const T& geom){
double *a = min_node()->location;
double *b = max_node()->location;
if(geom.intersects_cell(a, b)){
if(this->is_leaf()){
cells.push_back(index);
return;
}
for(int_t i = 0; i < (1<<n_dim); ++i){
children[i]->find_cells_geom(cells, geom);
}
}
}
};
class Tree{
public:
int_t n_dim;
std::vector<std::vector<std::vector<Cell *> > > roots;
int_t max_level, nx, ny, nz;
int_t *ixs, *iys, *izs;
int_t nx_roots, ny_roots, nz_roots;
double *xs;
double *ys;
double *zs;
std::vector<Cell *> cells;
node_map_t nodes;
edge_map_t edges_x, edges_y, edges_z;
face_map_t faces_x, faces_y, faces_z;
std::vector<Node *> hanging_nodes;
std::vector<Edge *> hanging_edges_x, hanging_edges_y, hanging_edges_z;
std::vector<Face *> hanging_faces_x, hanging_faces_y, hanging_faces_z;
Tree();
~Tree();
void set_dimension(int_t dim);
void set_levels(int_t l_x, int_t l_y, int_t l_z);
void set_xs(double *x , double *y, double *z);
void initialize_roots();
void number();
void finalize_lists();
void shift_cell_centers(double *shift);
void insert_cell(double *new_center, int_t p_level, bool diagonal_balance=false);
Cell* containing_cell(double, double, double);
void refine_function(function test_func, bool diagonal_balance=false);
void refine_image(double* image, bool diagonal_balance=false);
template <class T>
void refine_geom(const T& geom, int_t p_level, bool diagonal_balance=false){
for(int_t iz=0; iz<nz_roots; ++iz)
for(int_t iy=0; iy<ny_roots; ++iy)
for(int_t ix=0; ix<nx_roots; ++ix)
roots[iz][iy][ix]->refine_geom(nodes, geom, p_level, xs, ys, zs, diagonal_balance);
};
template <class T>
int_vec_t find_cells_geom(const T& geom){
int_vec_t intersections;
for(int_t iz=0; iz<nz_roots; ++iz){
for(int_t iy=0; iy<ny_roots; ++iy){
for(int_t ix=0; ix<nx_roots; ++ix){
roots[iz][iy][ix]->find_cells_geom(intersections, geom);
}
}
}
return intersections;
};
};
#endif
================================================
FILE: discretize/_extensions/tree.pxd
================================================
from libcpp cimport bool
from libcpp.vector cimport vector
from libcpp.map cimport map
cdef extern from "tree.h":
ctypedef int int_t
cdef cppclass Node:
int_t location_ind[3]
double location[3]
int_t key
int_t reference
int_t index
bool hanging
Node *parents[4]
Node()
Node(int_t, int_t, int_t, double, double, double)
double operator[](int_t)
cdef cppclass Edge:
int_t location_ind[3]
double location[3]
int_t key
int_t reference
int_t index
double length
bool hanging
Node *points[2]
Edge *parents[2]
Edge()
Edge(Node& p1, Node& p2)
double operator[](int_t)
cdef cppclass Face:
int_t location_ind[3]
double location[3]
int_t key
int_t reference
int_t index
double area
bool hanging
Node *points[4]
Edge *edges[4]
Face *parent
Face()
Face(Node& p1, Node& p2, Node& p3, Node& p4)
double operator[](int_t)
ctypedef map[int_t, Node *] node_map_t
ctypedef map[int_t, Edge *] edge_map_t
ctypedef map[int_t, Face *] face_map_t
cdef cppclass Cell:
int_t n_dim
Cell *parent
Cell *children[8]
Cell *neighbors[6]
Node *points[8]
Edge *edges[12]
Face *faces[6]
int_t location_ind[3]
double location[3]
int_t key, level, max_level
long long int index
double volume
inline bool is_leaf()
inline Node* min_node()
inline Node* max_node()
double operator[](int_t)
ctypedef int (*eval_func_ptr)(void*, Cell*)
cdef cppclass PyWrapper:
PyWrapper()
void set(void*, eval_func_ptr eval)
cdef cppclass Tree:
int_t n_dim
int_t max_level, nx, ny, nz
vector[Cell *] cells
node_map_t nodes
edge_map_t edges_x, edges_y, edges_z
face_map_t faces_x, faces_y, faces_z
vector[Node *] hanging_nodes
vector[Edge *] hanging_edges_x, hanging_edges_y, hanging_edges_z
vector[Face *] hanging_faces_x, hanging_faces_y, hanging_faces_z
Tree()
void set_dimension(int_t)
void set_levels(int_t, int_t, int_t)
void set_xs(double*, double*, double*)
void refine_function(PyWrapper *, bool)
void refine_geom[T](const T&, int_t, bool)
void refine_image(double*, bool)
void number()
void initialize_roots()
void insert_cell(double *new_center, int_t p_level, bool)
void finalize_lists()
Cell * containing_cell(double, double, double)
vector[int_t] find_cells_geom[T](const T& geom)
void shift_cell_centers(double*)
================================================
FILE: discretize/_extensions/tree_ext.pyx
================================================
# distutils: language=c++
# cython: embedsignature=True, language_level=3
# cython: linetrace=True
# cython: freethreading_compatible=True
cimport cython
cimport numpy as np
from libc.stdlib cimport malloc, free
from libcpp.vector cimport vector
from libcpp cimport bool
from libc.math cimport INFINITY
from .tree cimport int_t, Tree as c_Tree, PyWrapper, Node, Edge, Face, Cell as c_Cell
from . cimport geom
import scipy.sparse as sp
import numpy as np
from .interputils_cython cimport _bisect_left, _bisect_right
class TreeMeshNotFinalizedError(RuntimeError):
"""Raise when a TreeMesh is not finalized."""
cdef class TreeCell:
"""A class for defining cells within instances of :class:`~discretize.TreeMesh`.
This cannot be created in python, it can only be accessed by indexing the
:class:`~discretize.TreeMesh` object. ``TreeCell`` is the object being passed
to the user defined refine function when calling the
:py:attr:`~discretize.TreeMesh.refine` method for a :class:`~discretize.TreeMesh`.
Examples
--------
Here, we define a basic :class:`~discretize.TreeMesh` whose refinement is defined
by a simple function handle. After we have finalized the mesh, we index a ``TreeCell``
from the mesh. Once indexed, the user may examine its properties (center location,
dimensions, index of its neighbors, etc...)
>>> from discretize import TreeMesh
>>> import numpy as np
Refine a tree mesh radially outward from the center
>>> mesh = TreeMesh([32,32])
>>> def func(cell):
... r = np.linalg.norm(cell.center-0.5)
... return mesh.max_level if r<0.2 else mesh.max_level-2
>>> mesh.refine(func)
Then we can index the mesh to get access to the cell,
>>> tree_cell = mesh[16]
>>> tree_cell.origin
array([0.375, 0.25 ])
"""
cdef double _x, _y, _z, _x0, _y0, _z0, _wx, _wy, _wz
cdef int_t _dim
cdef c_Cell* _cell
cdef void _set(self, c_Cell* cell):
self._cell = cell
self._dim = cell.n_dim
@property
def nodes(self):
"""Indices for this cell's nodes within its parent tree mesh.
This property returns the indices of the nodes in the parent
tree mesh which correspond to this tree cell's nodes.
Returns
-------
list of int
Indices for this cell's nodes within its parent tree mesh
"""
cdef Node *points[8]
points = self._cell.points
if self._dim == 3:
return [points[0].index, points[1].index,
points[2].index, points[3].index,
points[4].index, points[5].index,
points[6].index, points[7].index]
return [points[0].index, points[1].index,
points[2].index, points[3].index]
@property
def edges(self):
"""Indices for this cell's edges within its parent tree mesh.
This property returns the indices of the edges in the parent
tree mesh which correspond to this tree cell's edges.
Returns
-------
list of int
Indices for this cell's edges within its parent tree mesh
"""
cdef Edge *edges[12]
edges = self._cell.edges
if self._dim == 2:
return [edges[0].index, edges[1].index,
edges[2].index, edges[3].index]
return [
edges[0].index, edges[1].index, edges[2].index, edges[3].index,
edges[4].index, edges[5].index, edges[6].index, edges[7].index,
edges[8].index, edges[9].index, edges[10].index, edges[11].index,
]
@property
def faces(self):
"""Indices for this cell's faces within its parent tree mesh.
This property returns the indices of the faces in the parent
tree mesh which correspond to this tree cell's faces.
Returns
-------
list of int
Indices for this cell's faces within its parent tree mesh
"""
cdef Face *faces[6]
faces = self._cell.faces
if self._dim == 3:
return [
faces[0].index, faces[1].index,
faces[2].index, faces[3].index,
faces[4].index, faces[5].index
]
cdef Edge *edges[12]
edges = self._cell.edges
return [edges[2].index, edges[3].index,
edges[0].index, edges[1].index]
@property
def center(self):
"""Cell center location for the tree cell.
Returns
-------
(dim) numpy.ndarray
Cell center location for the tree cell
"""
loc = self._cell.location
if self._dim == 2:
return np.array([loc[0], loc[1]])
return np.array([loc[0], loc[1], loc[2]])
@property
def origin(self):
"""Origin location ('anchor point') for the tree cell.
This property returns the origin location (or 'anchor point') for the
tree cell. The origin location is defined as the bottom-left-front
corner of the tree cell.
Returns
-------
(dim) numpy.ndarray
Origin location ('anchor point') for the tree cell
"""
loc = self._cell.min_node().location
if self._dim == 2:
return np.array([loc[0], loc[1]])
return np.array([loc[0], loc[1], loc[2]])
@property
def x0(self):
"""Origin location ('anchor point') for the tree cell.
This property returns the origin location (or 'anchor point') for the
tree cell. The origin location is defined as the bottom-left-front
corner of the tree cell.
Returns
-------
(dim) numpy.ndarray
Origin location ('anchor point') for the tree cell
"""
return self.origin
@property
def h(self):
"""Cell dimension along each axis direction.
This property returns a 1D array containing the dimensions of the
tree cell along the x, y (and z) directions, respectively.
Returns
-------
(dim) numpy.ndarray
Cell dimension along each axis direction
"""
loc_min = self._cell.min_node().location
loc_max = self._cell.max_node().location
if self._dim == 2:
return np.array([
loc_max[0] - loc_min[0],
loc_max[1] - loc_min[1],
])
return np.array([
loc_max[0] - loc_min[0],
loc_max[1] - loc_min[1],
loc_max[2] - loc_min[2],
])
@property
def dim(self):
"""Dimension of the tree cell; 1, 2 or 3.
Returns
-------
int
Dimension of the tree cell; 1, 2 or 3
"""
return self._dim
@property
def index(self):
"""Index of the tree cell within its parent tree mesh.
Returns
-------
int
Index of the tree cell within its parent tree mesh
"""
return self._cell.index
@property
def bounds(self):
"""
Bounds of the cell.
Coordinates that define the bounds of the cell. Bounds are returned in
the following order: ``x0``, ``x1``, ``y0``, ``y1``, ``z0``, ``z1``.
Returns
-------
bounds : (2 * dim) array
Array with the cell bounds.
"""
loc_min = self._cell.min_node().location
loc_max = self._cell.max_node().location
if self.dim == 2:
return np.array(
[
loc_min[0],
loc_max[0],
loc_min[1],
loc_max[1],
]
)
return np.array(
[
loc_min[0],
loc_max[0],
loc_min[1],
loc_max[1],
loc_min[2],
loc_max[2],
]
)
@property
def neighbors(self):
"""Indices for this cell's neighbors within its parent tree mesh.
Returns a list containing the indexes for the cell's neighbors.
The ordering of the neighboring cells (i.e. the list) is
[-x, +x, -y, +y, -z, +z]. For each entry in the list, there
are several cases:
- *ind >= 0:* the cell has a single neighbor in this direct and *ind* denotes its index
- *ind = -1:* the neighbour in this direction lies outside the mesh
- *ind = [ind_1, ind_2, ...]:* When the level changes between cells it shares a boarder with more than 1 cell in this direction (2 if `dim==2`, 4 if `dim==3`).
Returns
-------
list of int or (list of int)
Indices for this cell's neighbors within its parent tree mesh
"""
neighbors = [-1]*self._dim*2
for i in range(self._dim*2):
neighbor = self._cell.neighbors[i]
if neighbor is NULL:
continue
elif neighbor.is_leaf():
neighbors[i] = neighbor.index
else:
if self._dim==2:
if i==0:
neighbors[i] = [neighbor.children[1].index,
neighbor.children[3].index]
elif i==1:
neighbors[i] = [neighbor.children[0].index,
neighbor.children[2].index]
elif i==2:
neighbors[i] = [neighbor.children[2].index,
neighbor.children[3].index]
else:
neighbors[i] = [neighbor.children[0].index,
neighbor.children[1].index]
else:
if i==0:
neighbors[i] = [neighbor.children[1].index,
neighbor.children[3].index,
neighbor.children[5].index,
neighbor.children[7].index]
elif i==1:
neighbors[i] = [neighbor.children[0].index,
neighbor.children[2].index,
neighbor.children[4].index,
neighbor.children[6].index]
elif i==2:
neighbors[i] = [neighbor.children[2].index,
neighbor.children[3].index,
neighbor.children[6].index,
neighbor.children[7].index]
elif i==3:
neighbors[i] = [neighbor.children[0].index,
neighbor.children[1].index,
neighbor.children[4].index,
neighbor.children[5].index]
elif i==4:
neighbors[i] = [neighbor.children[4].index,
neighbor.children[5].index,
neighbor.children[6].index,
neighbor.children[7].index]
else:
neighbors[i] = [neighbor.children[0].index,
neighbor.children[1].index,
neighbor.children[2].index,
neighbor.children[3].index]
return neighbors
@property
def _index_loc(self):
loc_ind = self._cell.location_ind
if self._dim == 2:
return tuple((loc_ind[0], loc_ind[1]))
return tuple((loc_ind[0], loc_ind[1], loc_ind[2]))
@property
def _level(self):
return self._cell.level
cdef int _evaluate_func(void* function, c_Cell* cell) noexcept with gil:
# Wraps a function to be called in C++
func = <object> function
pycell = TreeCell()
pycell._set(cell)
return <int> func(pycell)
cdef class _TreeMesh:
cdef c_Tree *tree
cdef PyWrapper *wrapper
cdef int_t _dim
cdef int_t[3] ls
cdef int _finalized
cdef bool _diagonal_balance
cdef cython.pymutex _tree_modify_lock
cdef double[:] _xs, _ys, _zs
cdef double[:] _origin
cdef object _cell_centers, _nodes, _hanging_nodes
cdef object _edges_x, _edges_y, _edges_z, _hanging_edges_x, _hanging_edges_y, _hanging_edges_z
cdef object _faces_x, _faces_y, _faces_z, _hanging_faces_x, _hanging_faces_y, _hanging_faces_z
cdef object _h_gridded
cdef object _cell_volumes, _face_areas, _edge_lengths
cdef object _average_face_x_to_cell, _average_face_y_to_cell, _average_face_z_to_cell, _average_face_to_cell, _average_face_to_cell_vector
cdef object _average_node_to_cell, _average_node_to_edge, _average_node_to_edge_x, _average_node_to_edge_y, _average_node_to_edge_z
cdef object _average_node_to_face, _average_node_to_face_x, _average_node_to_face_y, _average_node_to_face_z
cdef object _average_edge_x_to_cell, _average_edge_y_to_cell, _average_edge_z_to_cell, _average_edge_to_cell, _average_edge_to_cell_vector
cdef object _average_cell_to_face, _average_cell_vector_to_face, _average_cell_to_face_x, _average_cell_to_face_y, _average_cell_to_face_z
cdef object _face_divergence
cdef object _edge_curl, _nodal_gradient
cdef object __ubc_order, __ubc_indArr
def __cinit__(self, *args, **kwargs):
self.wrapper = new PyWrapper()
self.tree = new c_Tree()
def __init__(self, h, origin, bool diagonal_balance=False):
super().__init__(h=h, origin=origin)
def is_pow2(num):
return ((num & (num - 1)) == 0) and num != 0
for n in self.shape_cells:
if not is_pow2(n):
raise ValueError("length of cell width vectors must be a power of 2")
h = self.h
origin = self.origin
nx2 = 2*len(h[0])
ny2 = 2*len(h[1])
self._dim = len(origin)
self._origin = origin
xs = np.empty(nx2 + 1, dtype=float)
xs[::2] = np.cumsum(np.r_[origin[0], h[0]])
xs[1::2] = (xs[:-1:2] + xs[2::2])/2
self._xs = xs
self.ls[0] = int(np.log2(len(h[0])))
ys = np.empty(ny2 + 1, dtype=float)
ys[::2] = np.cumsum(np.r_[origin[1],h[1]])
ys[1::2] = (ys[:-1:2] + ys[2::2])/2
self._ys = ys
self.ls[1] = int(np.log2(len(h[1])))
if self._dim > 2:
nz2 = 2*len(h[2])
zs = np.empty(nz2 + 1, dtype=float)
zs[::2] = np.cumsum(np.r_[origin[2],h[2]])
zs[1::2] = (zs[:-1:2] + zs[2::2])/2
self._zs = zs
self.ls[2] = int(np.log2(len(h[2])))
else:
self._zs = np.zeros(1, dtype=float)
self.ls[2] = 1
self.tree.set_dimension(self._dim)
self.tree.set_levels(self.ls[0], self.ls[1], self.ls[2])
self.tree.set_xs(&self._xs[0], &self._ys[0], &self._zs[0])
self.tree.initialize_roots()
self._finalized = False
self._diagonal_balance = diagonal_balance
self._clear_cache()
def _clear_cache(self):
self._cell_centers = None
self._nodes = None
self._hanging_nodes = None
self._h_gridded = None
self._edges_x = None
self._edges_y = None
self._edges_z = None
self._hanging_edges_x = None
self._hanging_edges_y = None
self._hanging_edges_z = None
self._faces_x = None
self._faces_y = None
self._faces_z = None
self._hanging_faces_x = None
self._hanging_faces_y = None
self._hanging_faces_z = None
self._cell_volumes = None
self._face_areas = None
self._edge_lengths = None
self._average_cell_to_face = None
self._average_cell_to_face_x = None
self._average_cell_to_face_y = None
self._average_cell_to_face_z = None
self._average_face_x_to_cell = None
self._average_face_y_to_cell = None
self._average_face_z_to_cell = None
self._average_face_to_cell = None
self._average_face_to_cell_vector = None
self._average_edge_x_to_cell = None
self._average_edge_y_to_cell = None
self._average_edge_z_to_cell = None
self._average_edge_to_cell = None
self._average_edge_to_cell_vector = None
self._average_edge_to_face = None
self._average_node_to_cell = None
self._average_node_to_edge = None
self._average_node_to_face = None
self._average_node_to_edge_x = None
self._average_node_to_edge_y = None
self._average_node_to_edge_z = None
self._average_node_to_face_x = None
self._average_node_to_face_y = None
self._average_node_to_face_z = None
self._face_divergence = None
self._nodal_gradient = None
self._edge_curl = None
self.__ubc_order = None
self.__ubc_indArr = None
def refine(self, function, finalize=True, diagonal_balance=None):
"""Refine :class:`~discretize.TreeMesh` with user-defined function.
Refines the :class:`~discretize.TreeMesh` according to a user-defined function.
The function is recursively called on each cell of the mesh. The user-defined
function **must** accept an object of type :class:`~discretize.tree_mesh.TreeCell`
and **must** return an integer-like object denoting the desired refinement
level. Instead of a function, the user may also supply an integer defining
the minimum refinement level for all cells.
Parameters
----------
function : callable or int
a function defining the desired refinement level,
or an integer to refine all cells to at least that level.
The input argument of the function **must** be an instance of
:class:`~discretize.tree_mesh.TreeCell`.
finalize : bool, optional
whether to finalize the mesh
diagonal_balance : bool or None, optional
Whether to balance cells diagonally in the refinement, `None` implies using
the same setting used to instantiate the TreeMesh`.
Examples
--------
Here, we define a QuadTree mesh with a domain width of 1 along
the x and y axes. We then refine the mesh to its maximum level
at locations within a distance of 0.2 of point (0.5, 0.5). The
function accepts and instance of :class:`~discretize.tree_mesh.TreeCell`
and returns an integer value denoting its level of refinement.
>>> from discretize import TreeMesh
>>> from matplotlib import pyplot
Define a mesh and refine it radially outward using the custom defined function
>>> mesh = TreeMesh([32,32])
>>> def func(cell):
... r = np.linalg.norm(cell.center-0.5)
... return mesh.max_level if r<0.2 else mesh.max_level-2
>>> mesh.refine(func)
>>> mesh.plot_grid()
>>> pyplot.show()
"""
if isinstance(function, int):
level = function
function = lambda cell: level
if diagonal_balance is None:
diagonal_balance = self._diagonal_balance
cdef bool diag_balance = diagonal_balance
#Wrapping function so it can be called in c++
cdef void * func_ptr = <void *> function
with self._tree_modify_lock:
self.wrapper.set(func_ptr, _evaluate_func)
#Then tell c++ to build the tree
self.tree.refine_function(self.wrapper, diag_balance)
if finalize:
self.finalize()
@cython.cdivision(True)
def refine_ball(self, points, radii, levels, finalize=True, diagonal_balance=None):
"""Refine :class:`~discretize.TreeMesh` using radial distance (ball) and refinement level for a cluster of points.
For each point in the array `points`, this method refines the tree mesh
based on the radial distance (ball) and refinement level supplied. The method
accomplishes this by determining which cells intersect ball(s) and refining them
to the prescribed level(s) of refinement.
Parameters
----------
points : (N, dim) array_like
The centers of the refinement balls
radii : float or (N) array_like of float
A 1D array defining the radius for each ball
levels : int or (N) array_like of int
A 1D array defining the maximum refinement level for each ball
finalize : bool, optional
Whether to finalize after refining
diagonal_balance : bool or None, optional
Whether to balance cells diagonally in the refinement, `None` implies using
the same setting used to instantiate the TreeMesh`.
Examples
--------
We create a simple mesh and refine the tree mesh such that all cells that
intersect the spherical balls are at the given levels.
>>> import discretize
>>> import matplotlib.pyplot as plt
>>> import matplotlib.patches as patches
>>> tree_mesh = discretize.TreeMesh([32, 32])
>>> tree_mesh.max_level
5
Next we define the center and radius of the two spheres, as well as the level
we want to refine them to, and refine the mesh.
>>> centers = [[0.1, 0.3], [0.6, 0.8]]
>>> radii = [0.2, 0.3]
>>> levels = [4, 5]
>>> tree_mesh.refine_ball(centers, radii, levels)
Now lets look at the mesh, and overlay the balls on it to ensure it refined
where we wanted it to.
>>> ax = tree_mesh.plot_grid()
>>> circ = patches.Circle(centers[0], radii[0], facecolor='none', edgecolor='r', linewidth=3)
>>> ax.add_patch(circ)
>>> circ = patches.Circle(centers[1], radii[1], facecolor='none', edgecolor='k', linewidth=3)
>>> ax.add_patch(circ)
>>> plt.show()
"""
points = self._require_ndarray_with_dim('points', points, ndim=2, dtype=np.float64)
radii = np.require(np.atleast_1d(radii), dtype=np.float64, requirements='C')
levels = np.require(np.atleast_1d(levels), dtype=np.int32, requirements='C')
cdef int_t n_balls = _check_first_dim_broadcast(points=points, radii=radii, levels=levels)
cdef double[:, :] cs = points
cdef double[:] rs = radii
cdef int[:] ls = levels
cdef int_t cs_step = cs.shape[0] > 1
cdef int_t rs_step = rs.shape[0] > 1
cdef int_t l_step = ls.shape[0] > 1
cdef int_t i_c=0, i_r=0, i_l=0
if diagonal_balance is None:
diagonal_balance = self._diagonal_balance
cdef bool diag_balance = diagonal_balance
cdef geom.Ball ball
cdef int_t i
cdef int l
cdef int max_level = self.max_level
for i in range(n_balls):
ball = geom.Ball(self._dim, &cs[i_c, 0], rs[i_r])
l = _wrap_levels(ls[i_l], max_level)
with self._tree_modify_lock:
self.tree.refine_geom(ball, l, diag_balance)
i_c += cs_step
i_r += rs_step
i_l += l_step
if finalize:
self.finalize()
@cython.cdivision(True)
def refine_box(self, x0s, x1s, levels, finalize=True, diagonal_balance=None):
"""Refine the :class:`~discretize.TreeMesh` within the axis aligned boxes to the desired level.
Refines the TreeMesh by determining if a cell intersects the given axis aligned
box(es) to the prescribed level(s).
Parameters
----------
x0s : (N, dim) array_like
The minimum location of the boxes
x1s : (N, dim) array_like
The maximum location of the boxes
levels : int or (N) array_like of int
The level to refine intersecting cells to
finalize : bool, optional
Whether to finalize after refining
diagonal_balance : None or bool, optional
Whether to balance cells diagonally in the refinement, `None` implies using
the same setting used to instantiate the TreeMesh`.
Examples
--------
We create a simple mesh and refine the TreeMesh such that all cells that
intersect the boxes are at the given levels.
>>> import discretize
>>> import matplotlib.pyplot as plt
>>> import matplotlib.patches as patches
>>> tree_mesh = discretize.TreeMesh([32, 32])
>>> tree_mesh.max_level
5
Next we define the origins and furthest corners of the two rectangles, as
well as the level we want to refine them to, and refine the mesh.
>>> x0s = [[0.1, 0.1], [0.8, 0.8]]
>>> x1s = [[0.3, 0.2], [0.9, 1.0]]
>>> levels = [4, 5]
>>> tree_mesh.refine_box(x0s, x1s, levels)
Now lets look at the mesh, and overlay the boxes on it to ensure it refined
where we wanted it to.
>>> ax = tree_mesh.plot_grid()
>>> rect = patches.Rectangle([0.1, 0.1], 0.2, 0.1, facecolor='none', edgecolor='r', linewidth=3)
>>> ax.add_patch(rect)
>>> rect = patches.Rectangle([0.8, 0.8], 0.1, 0.2, facecolor='none', edgecolor='k', linewidth=3)
>>> ax.add_patch(rect)
>>> plt.show()
"""
x0s = self._require_ndarray_with_dim('x0s', x0s, ndim=2, dtype=np.float64)
x1s = self._require_ndarray_with_dim('x1s', x1s, ndim=2, dtype=np.float64)
levels = np.require(np.atleast_1d(levels), dtype=np.int32, requirements='C')
cdef int_t n_boxes = _check_first_dim_broadcast(x0s=x0s, x1s=x1s, levels=levels)
cdef double[:, :] x0 = x0s
cdef double[:, :] x1 = x1s
cdef int[:] ls = levels
cdef int_t x0_step = x0.shape[0] > 1
cdef int_t x1_step = x1.shape[0] > 1
cdef int_t l_step = ls.shape[0] > 1
cdef int_t i_x0=0, i_x1=0, i_l=0
if diagonal_balance is None:
diagonal_balance = self._diagonal_balance
cdef bool diag_balance = diagonal_balance
cdef geom.Box box
cdef int l
cdef int max_level = self.max_level
for i in range(n_boxes):
box = geom.Box(self._dim, &x0[i_x0, 0], &x1[i_x1, 0])
l = _wrap_levels(ls[i_l], max_level)
with self._tree_modify_lock:
self.tree.refine_geom(box, l, diag_balance)
i_x0 += x0_step
i_x1 += x1_step
i_l += l_step
if finalize:
self.finalize()
@cython.cdivision(True)
def refine_line(self, path, levels, finalize=True, diagonal_balance=None):
"""Refine the :class:`~discretize.TreeMesh` along the line segment to the desired level.
Refines the TreeMesh by determining if a cell intersects the given line segment(s)
to the prescribed level(s).
Parameters
----------
path : (N+1, dim) array_like
The nodes of the line segment(s).
i.e. `[[x0, y0, z0], [x1, y1, z1], [x2, y2, z2]]` would be two segments.
levels : int or (N) array_like of int
The level to refine intersecting cells to.
finalize : bool, optional
Whether to finalize after refining
diagonal_balance : bool or None, optional
Whether to balance cells diagonally in the refinement, `None` implies using
the same setting used to instantiate the TreeMesh`.
Examples
--------
We create a simple mesh and refine the TreeMesh such that all cells that
intersect the line segment path are at the given levels.
>>> import discretize
>>> import matplotlib.pyplot as plt
>>> import matplotlib.patches as patches
>>> tree_mesh = discretize.TreeMesh([32, 32])
>>> tree_mesh.max_level
5
Next we define the points along the line and the level we want to refine to,
and refine the mesh.
>>> segments = np.array([[0.1, 0.3], [0.3, 0.9], [0.8, 0.9]])
>>> levels = 5
>>> tree_mesh.refine_line(segments, levels)
Now lets look at the mesh, and overlay the line on it to ensure it refined
where we wanted it to.
>>> ax = tree_mesh.plot_grid()
>>> ax.plot(*segments.T, color='C1')
>>> plt.show()
"""
path = self._require_ndarray_with_dim('path', path, ndim=2, dtype=np.float64)
levels = np.require(np.atleast_1d(levels), dtype=np.int32, requirements='C')
cdef int_t n_segments = _check_first_dim_broadcast(path=path[:-1], levels=levels)
cdef double[:, :] line_nodes = path
cdef int[:] ls = levels
cdef int_t line_step = line_nodes.shape[0] > 2
cdef int_t l_step = levels.shape[0] > 1
cdef int_t i_line=0, i_l=0
if diagonal_balance is None:
diagonal_balance = self._diagonal_balance
cdef bool diag_balance = diagonal_balance
cdef geom.Line line
cdef int l
cdef int max_level = self.max_level
cdef int i
for i in range(n_segments):
line = geom.Line(self._dim, &line_nodes[i_line, 0], &line_nodes[i_line+1, 0])
l = _wrap_levels(ls[i_l], max_level)
with self._tree_modify_lock:
self.tree.refine_geom(line, l, diag_balance)
i_line += line_step
i_l += l_step
if finalize:
self.finalize()
@cython.cdivision(True)
def refine_plane(self, origins, normals, levels, finalize=True, diagonal_balance=None):
"""Refine the :class:`~discretize.TreeMesh` along a plane to the desired level.
Refines the TreeMesh by determining if a cell intersects the given plane(s)
to the prescribed level(s).
Parameters
----------
origins : (dim) or (N, dim) array_like of float
The origin of the planes.
normals : (dim) or (N, dim) array_like of float
The normals to the planes.
levels : int or (N) array_like of int
The level to refine intersecting cells to.
finalize : bool, optional
Whether to finalize after refining.
diagonal_balance : bool or None, optional
Whether to balance cells diagonally in the refinement, `None` implies using
the same setting used to instantiate the TreeMesh`.
Examples
--------
We create a simple mesh and refine the TreeMesh such that all cells that
intersect the plane path are at the given levels. (In 2D, the plane is also a
line.)
>>> import discretize
>>> import matplotlib.pyplot as plt
>>> tree_mesh = discretize.TreeMesh([32, 32])
>>> tree_mesh.max_level
5
Next we define the origin and normal of the plane, and the level we want
to refine to.
>>> origin = [0, 0.25]
>>> normal = [-1, -1]
>>> level = -1
>>> tree_mesh.refine_plane(origin, normal, level)
Now lets look at the mesh, and overlay the plane on it to ensure it refined
where we wanted it to.
>>> ax = tree_mesh.plot_grid()
>>> ax.axline(origin, slope=-normal[0]/normal[1], color='C1')
>>> plt.show()
"""
origins = self._require_ndarray_with_dim('origins', origins, ndim=2, dtype=np.float64)
normals = self._require_ndarray_with_dim('normals', normals, ndim=2, dtype=np.float64)
levels = np.require(np.atleast_1d(levels), dtype=np.int32, requirements='C')
cdef int n_planes = _check_first_dim_broadcast(origins=origins, normals=normals, levels=levels)
cdef double[:, :] x_0s = origins
cdef double[:, :] norms = normals
cdef int[:] ls = levels
cdef int_t origin_step = x_0s.shape[0] > 1
cdef int_t normal_step = norms.shape[0] > 1
cdef int_t level_step = ls.shape[0] > 1
cdef int_t i_o=0, i_n=0, i_l=0
if diagonal_balance is None:
diagonal_balance = self._diagonal_balance
cdef bool diag_balance = diagonal_balance
cdef geom.Plane plane
cdef int l
cdef int max_level = self.max_level
cdef int i_plane
for i in range(n_planes):
plane = geom.Plane(self._dim, &x_0s[i_o, 0], &norms[i_n, 0])
l = _wrap_levels(ls[i_l], max_level)
with self._tree_modify_lock:
self.tree.refine_geom(plane, l, diag_balance)
i_o += origin_step
i_n += normal_step
i_l += level_step
if finalize:
self.finalize()
@cython.cdivision(True)
def refine_triangle(self, triangle, levels, finalize=True, diagonal_balance=None):
"""Refine the :class:`~discretize.TreeMesh` along the triangle to the desired level.
Refines the TreeMesh by determining if a cell intersects the given triangle(s)
to the prescribed level(s).
Parameters
----------
triangle : (N, 3, dim) array_like
The nodes of the triangle(s).
levels : int or (N) array_like of int
The level to refine intersecting cells to.
finalize : bool, optional
Whether to finalize after refining
diagonal_balance : bool or None, optional
Whether to balance cells diagonally in the refinement, `None` implies using
the same setting used to instantiate the TreeMesh`.
Examples
--------
We create a simple mesh and refine the TreeMesh such that all cells that
intersect the line segment path are at the given levels.
>>> import discretize
>>> import matplotlib.pyplot as plt
>>> import matplotlib.patches as patches
>>> tree_mesh = discretize.TreeMesh([32, 32])
>>> tree_mesh.max_level
5
Next we define the points along the line and the level we want to refine to,
and refine the mesh.
>>> triangle = [[0.14, 0.31], [0.32, 0.96], [0.23, 0.87]]
>>> levels = 5
>>> tree_mesh.refine_triangle(triangle, levels)
Now lets look at the mesh, and overlay the line on it to ensure it refined
where we wanted it to.
>>> ax = tree_mesh.plot_grid()
>>> tri = patches.Polygon(triangle, fill=False)
>>> ax.add_patch(tri)
>>> plt.show()
"""
triangle = self._require_ndarray_with_dim('triangle', triangle, ndim=3, dtype=np.float64)
if triangle.shape[-2] != 3:
raise ValueError(f"triangle array must be (N, 3, {self.dim})")
levels = np.require(np.atleast_1d(levels), dtype=np.int32, requirements='C')
cdef int n_triangles = _check_first_dim_broadcast(triangle=triangle, levels=levels)
cdef double[:, :, :] tris = triangle
cdef int[:] ls = levels
cdef int_t tri_step = tris.shape[0] > 1
cdef int_t l_step = ls.shape[0] > 1
cdef int_t i_tri=0, i_l=0
if diagonal_balance is None:
diagonal_balance = self._diagonal_balance
cdef bool diag_balance = diagonal_balance
cdef geom.Triangle triang
cdef int l
cdef int max_level = self.max_level
for i in range(n_triangles):
triang = geom.Triangle(self._dim, &tris[i_tri, 0, 0], &tris[i_tri, 1, 0], &tris[i_tri, 2, 0])
l = _wrap_levels(ls[i_l], max_level)
with self._tree_modify_lock:
self.tree.refine_geom(triang, l, diag_balance)
i_tri += tri_step
i_l += l_step
if finalize:
self.finalize()
@cython.cdivision(True)
def refine_vertical_trianglular_prism(self, triangle, h, levels, finalize=True, diagonal_balance=None):
"""Refine the :class:`~discretize.TreeMesh` along the trianglular prism to the desired level.
Refines the TreeMesh by determining if a cell intersects the given trianglular prism(s)
to the prescribed level(s).
Parameters
----------
triangle : (N, 3, dim) array_like
The nodes of the bottom triangle(s).
h : (N) array_like
The height of the prism(s).
levels : int or (N) array_like of int
The level to refine intersecting cells to.
finalize : bool, optional
Whether to finalize after refining
diagonal_balance : bool or None, optional
Whether to balance cells diagonally in the refinement, `None` implies using
the same setting used to instantiate the TreeMesh`.
See Also
--------
refine_surface
Examples
--------
We create a simple mesh and refine the TreeMesh such that all cells that
intersect the line segment path are at the given levels.
>>> import discretize
>>> import matplotlib.pyplot as plt
>>> import matplotlib.patches as patches
>>> mesh = discretize.TreeMesh([32, 32, 32])
>>> mesh.max_level
5
Next we define the bottom points of the prism, its heights, and the level we
want to refine to, then refine the mesh.
>>> 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)
Now lets look at the mesh.
>>> v = mesh.cell_levels_by_index(np.arange(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])
>>> plt.show()
"""
if self.dim == 2:
raise NotImplementedError("refine_vertical_trianglular_prism only implemented in 3D.")
triangle = self._require_ndarray_with_dim('triangle', triangle, ndim=3, dtype=np.float64)
if triangle.shape[-2] != 3:
raise ValueError(f"triangle array must be (N, 3, {self.dim})")
h = np.require(np.atleast_1d(h), dtype=np.float64, requirements="C")
if np.any(h < 0):
raise ValueError("All heights must be positive.")
levels = np.require(np.atleast_1d(levels), dtype=np.int32, requirements='C')
cdef int_t n_triangles = _check_first_dim_broadcast(triangle=triangle, h=h, levels=levels)
cdef double[:, :, :] tris = triangle
cdef double[:] hs = h
cdef int[:] ls = levels
cdef int_t tri_step = tris.shape[0] > 1
cdef int_t h_step = hs.shape[0] > 1
cdef int_t l_step = ls.shape[0] > 1
cdef int_t i_tri=0, i_h=0, i_l=0
if diagonal_balance is None:
diagonal_balance = self._diagonal_balance
cdef bool diag_balance = diagonal_balance
cdef geom.VerticalTriangularPrism vert_prism
cdef int l
cdef int max_level = self.max_level
for i in range(n_triangles):
vert_prism = geom.VerticalTriangularPrism(self._dim, &tris[i_tri, 0, 0], &tris[i_tri, 1, 0], &tris[i_tri, 2, 0], hs[i_h])
l = _wrap_levels(ls[i_l], max_level)
with self._tree_modify_lock:
self.tree.refine_geom(vert_prism, l, diag_balance)
i_tri += tri_step
i_h += h_step
i_l += l_step
if finalize:
self.finalize()
@cython.cdivision(True)
def refine_tetrahedron(self, tetra, levels, finalize=True, diagonal_balance=None):
"""Refine the :class:`~discretize.TreeMesh` along the tetrahedron to the desired level.
Refines the TreeMesh by determining if a cell intersects the given triangle(s)
to the prescribed level(s).
Parameters
----------
tetra : (N, dim+1, dim) array_like
The nodes of the tetrahedron(s).
levels : int or (N) array_like of int
The level to refine intersecting cells to.
finalize : bool, optional
Whether to finalize after refining
diagonal_balance : bool or None, optional
Whether to balance cells diagonally in the refinement, `None` implies using
the same setting used to instantiate the TreeMesh`.
Examples
--------
We create a simple mesh and refine the TreeMesh such that all cells that
intersect the line segment path are at the given levels.
>>> import discretize
>>> import matplotlib.pyplot as plt
>>> import matplotlib.patches as patches
>>> tree_mesh = discretize.TreeMesh([32, 32, 32])
>>> tree_mesh.max_level
5
Next we define the points along the line and the level we want to refine to,
and refine the mesh.
>>> tetra = [
... [0.32, 0.21, 0.15],
... [0.82, 0.19, 0.34],
... [0.14, 0.82, 0.29],
... [0.32, 0.27, 0.83],
... ]
>>> levels = 5
>>> tree_mesh.refine_tetrahedron(tetra, levels)
Now lets look at the mesh, checking how the refine function proceeded.
>>> levels = tree_mesh.cell_levels_by_index(np.arange(tree_mesh.n_cells))
>>> ax = plt.gca()
>>> tree_mesh.plot_slice(levels, normal='z', slice_loc=0.2, grid=True, ax=ax)
>>> plt.show()
"""
if self.dim == 2:
return self.refine_triangle(tetra, levels, finalize=finalize, diagonal_balance=diagonal_balance)
tetra = self._require_ndarray_with_dim('tetra', tetra, ndim=3, dtype=np.float64)
if tetra.shape[-2] != self.dim+1:
raise ValueError(f"tetra array must be (N, {self.dim+1}, {self.dim})")
levels = np.require(np.atleast_1d(levels), dtype=np.int32, requirements='C')
cdef int_t n_triangles = _check_first_dim_broadcast(tetra=tetra, levels=levels)
cdef double[:, :, :] tris = tetra
cdef int[:] ls = levels
cdef int_t tri_step = tris.shape[0] > 1
cdef int_t l_step = ls.shape[0] > 1
cdef int_t i_tri=0, i_l=0
if diagonal_balance is None:
diagonal_balance = self._diagonal_balance
cdef bool diag_balance = diagonal_balance
cdef geom.Tetrahedron tet
cdef int l
cdef int max_level = self.max_level
for i in range(n_triangles):
l = _wrap_levels(ls[i_l], max_level)
tet = geom.Tetrahedron(self._dim, &tris[i_tri, 0, 0], &tris[i_tri, 1, 0], &tris[i_tri, 2, 0], &tris[i_tri, 3, 0])
with self._tree_modify_lock:
self.tree.refine_geom(tet, l, diag_balance)
i_tri += tri_step
i_l += l_step
if finalize:
self.finalize()
@cython.cdivision(True)
def insert_cells(self, points, levels, finalize=True, diagonal_balance=None):
"""Insert cells into the :class:`~discretize.TreeMesh` that contain given points.
Insert cell(s) into the :class:`~discretize.TreeMesh` that contain the given point(s) at the
assigned level(s).
Parameters
----------
points : (N, dim) array_like
levels : (N) array_like of int
finalize : bool, optional
Whether to finalize after inserting point(s)
diagonal_balance : bool or None, optional
Whether to balance cells diagonally in the refinement, `None` implies using
the same setting used to instantiate the TreeMesh`.
Examples
--------
>>> from discretize import TreeMesh
>>> mesh = TreeMesh([32,32])
>>> mesh.insert_cells([0.5, 0.5], mesh.max_level)
>>> mesh
QuadTreeMesh: 3.91%% filled
Level : Number of cells Mesh Extent Cell Widths
----------------------- min , max min , max
2 : 12 --------------------------- --------------------
3 : 13 x: 0.0 , 1.0 0.03125 , 0.25
4 : 11 y: 0.0 , 1.0 0.03125 , 0.25
5 : 4
-----------------------
Total : 40
"""
points = self._require_ndarray_with_dim('points', points, ndim=2, dtype=np.float64)
levels = np.require(np.atleast_1d(levels), dtype=np.int32, requirements='C')
cdef int_t n_points = _check_first_dim_broadcast(points=points, levels=levels)
cdef double[:, :] cs = points
cdef int[:] ls = levels
cdef int l
cdef int max_level = self.max_level
if diagonal_balance is None:
diagonal_balance = self._diagonal_balance
cdef bool diag_balance = diagonal_balance
cdef int_t p_step = cs.shape[0] > 1
cdef int_t l_step = ls.shape[0] > 1
cdef int_t i_p=0, i_l=0
for i in range(ls.shape[0]):
l = _wrap_levels(ls[i_l], max_level)
with self._tree_modify_lock:
self.tree.insert_cell(&cs[i_p, 0], l, diagonal_balance)
i_l += l_step
i_p += p_step
if finalize:
self.finalize()
def refine_image(self, image, finalize=True, diagonal_balance=None):
"""Refine using an ND image, ensuring that each cell contains exactly one unique value.
This function takes an N-dimensional image, defined on the underlying fine tensor mesh,
and recursively subdivides each cell if that cell contains more than 1 unique value in the
image. This is useful when using the `TreeMesh` to represent an exact compressed form of an input
model.
Parameters
----------
image : (shape_cells) numpy.ndarray
Must have the same shape as the base tensor mesh (`TreeMesh.shape_cells`), as if every cell on this mesh was
refined to it's maximum level.
finalize : bool, optional
Whether to finalize after inserting point(s)
diagonal_balance : bool or None, optional
Whether to balance cells diagonally in the refinement, `None` implies using
the same setting used to instantiate the `TreeMesh`.
"""
if diagonal_balance is None:
diagonal_balance = self._diagonal_balance
cdef bool diag_balance = diagonal_balance
image = np.require(image, dtype=np.float64, requirements="F")
cdef size_t n_expected = np.prod(self.shape_cells)
if image.size != n_expected:
raise ValueError(
f"image array size: {image.size} must match the total number of cells in the base tensor mesh: {n_expected}"
)
if image.ndim == 1:
image = image.reshape(self.shape_cells, order="F")
if image.shape != self.shape_cells:
raise ValueError(
f"image array shape: {image.shape} must match the base cell shapes: {self.shape_cells}"
)
if self.dim == 2:
image = image[..., None]
cdef double[::1,:,:] image_dat = image
with self._tree_modify_lock:
self.tree.refine_image(&image_dat[0, 0, 0], diag_balance)
if finalize:
self.finalize()
def finalize(self):
"""Finalize the :class:`~discretize.TreeMesh`.
Called once a tree mesh has been finalized; i.e. no further mesh
refinement will be carried out. The tree mesh must be finalized
before it can be used to call most of its properties or construct
operators. When finalized, mesh refinement is no longer enabled.
"""
with self._tree_modify_lock:
if not self._finalized:
self.tree.finalize_lists()
self.tree.number()
self._finalized=True
@property
def finalized(self):
"""Whether tree mesh is finalized.
This property returns a boolean stating whether the tree mesh has
been finalized; i.e. no further mesh refinement will be carried out.
A tree mesh must be finalized before it can be used to call most
of its properties or construct operators.
When finalized, mesh refinement is no longer enabled.
Returns
-------
bool
Returns *True* if finalized, *False* otherwise
"""
with self._tree_modify_lock:
val = self._finalized
return val
@property
@cython.boundscheck(False)
def cell_bounds(self):
cell_bounds = np.empty((self.n_cells, self.dim, 2), dtype=np.float64)
cdef np.float64_t[:, :, ::1] cell_bounds_view = cell_bounds
for cell in self.tree.cells:
min_loc = cell.min_node().location
max_loc = cell.max_node().location
for i in range(self._dim):
cell_bounds_view[cell.index, i, 0] = min_loc[i]
cell_bounds_view[cell.index, i, 1] = max_loc[i]
return cell_bounds.reshape((self.n_cells, -1))
def number(self):
"""Number the cells, nodes, faces, and edges of the TreeMesh."""
with self._tree_modify_lock:
self.tree.number()
def get_containing_cells(self, points):
"""Return the cells containing the given points.
Parameters
----------
points : (dim) or (n_point, dim) array_like
The locations to query for the containing cells
Returns
-------
int or (n_point) numpy.ndarray of int
The indexes of cells containing each point.
"""
cdef double[:,:] d_locs = self._require_ndarray_with_dim(
'locs', points, ndim=2, dtype=np.float64
)
cdef int_t n_locs = d_locs.shape[0]
cdef np.int64_t[:] indexes = np.empty(n_locs, dtype=np.int64)
cdef double x, y, z
for i in range(n_locs):
x = d_locs[i, 0]
y = d_locs[i, 1]
if self._dim == 3:
z = d_locs[i, 2]
else:
z = 0
indexes[i] = self.tree.containing_cell(x, y, z).index
if n_locs==1:
return indexes[0]
return np.array(indexes)
def get_cells_in_ball(self, center, double radius):
"""Find the indices of cells that intersect a ball
Parameters
----------
center : (dim) array_like
center of the ball.
radius : float
radius of the ball
Returns
-------
numpy.ndarray of int
The indices of cells which overlap the ball.
"""
cdef double[:] a = self._require_ndarray_with_dim('center', center, dtype=np.float64)
cdef geom.Ball ball = geom.Ball(self._dim, &a[0], radius)
return np.array(self.tree.find_cells_geom(ball))
def get_cells_on_line(self, segment):
"""Find the cells intersecting a line segment.
Parameters
----------
segment : (2, dim) array-like
Beginning and ending point of the line segment.
Returns
-------
numpy.ndarray of int
Indices for cells that intersect the line defined by the two input
points.
"""
segment = self._require_ndarray_with_dim('segment', segment, ndim=2, dtype=np.float64)
if segment.shape[0] != 2:
raise ValueError(f"A line segment has two points, not {segment.shape[0]}")
cdef double[:] start = segment[0]
cdef double[:] end = segment[1]
cdef geom.Line line = geom.Line(self._dim, &start[0], &end[0])
return np.array(self.tree.find_cells_geom(line))
def get_cells_in_aabb(self, x_min, x_max):
"""Find the indices of cells that intersect an axis aligned bounding box (aabb)
Parameters
----------
x_min : (dim, ) array_like
Minimum extent of the box.
x_max : (dim, ) array_like
Maximum extent of the box.
Returns
-------
numpy.ndarray of int
The indices of cells which overlap the axis aligned bounding box.
"""
cdef double[:] a = self._require_ndarray_with_dim('x_min', x_min, dtype=np.float64)
cdef double[:] b = self._require_ndarray_with_dim('x_max', x_max, dtype=np.float64)
cdef geom.Box box = geom.Box(self._dim, &a[0], &b[0])
return np.array(self.tree.find_cells_geom(box))
def get_cells_on_plane(self, origin, normal):
"""Find the indices of cells that intersect a plane.
Parameters
----------
origin : (dim) array_like
normal : (dim) array_like
Returns
-------
numpy.ndarray of int
The indices of cells which intersect the plane.
"""
cdef double[:] orig = self._require_ndarray_with_dim('origin', origin, dtype=np.float64)
cdef double[:] norm = self._require_ndarray_with_dim('normal', normal, dtype=np.float64)
cdef geom.Plane plane = geom.Plane(self._dim, &orig[0], &norm[0])
return np.array(self.tree.find_cells_geom(plane))
def get_cells_in_triangle(self, triangle):
"""Find the indices of cells that intersect a triangle.
Parameters
----------
triangle : (3, dim) array_like
The three points of the triangle.
Returns
-------
numpy.ndarray of int
The indices of cells which overlap the triangle.
"""
triangle = self._require_ndarray_with_dim('triangle', triangle, ndim=2, dtype=np.float64)
if triangle.shape[0] != 3:
raise ValueError(f"Triangle array must have three points, saw {triangle.shape[0]}")
cdef double[:, :] tri = triangle
cdef geom.Triangle poly = geom.Triangle(self._dim, &tri[0, 0], &tri[1, 0], &tri[2, 0])
return np.array(self.tree.find_cells_geom(poly))
def get_cells_in_vertical_trianglular_prism(self, triangle, double h):
"""Find the indices of cells that intersect a vertical triangular prism.
Parameters
----------
triangle : (3, dim) array_like
The three points of the triangle, assumes the top and bottom
faces are parallel.
h : float
The height of the prism.
Returns
-------
numpy.ndarray of int
The indices of cells which overlap the vertical triangular prism.
"""
if self.dim == 2:
raise NotImplementedError("vertical_trianglular_prism only implemented in 3D.")
triangle = self._require_ndarray_with_dim('triangle', triangle, ndim=2, dtype=np.float64)
if triangle.shape[0] != 3:
raise ValueError(f"Triangle array must have three points, saw {triangle.shape[0]}")
cdef double[:, :] tri = triangle
cdef geom.VerticalTriangularPrism vert = geom.VerticalTriangularPrism(self._dim, &tri[0, 0], &tri[1, 0], &tri[2, 0], h)
return np.array(self.tree.find_cells_geom(vert))
def get_cells_in_tetrahedron(self, tetra):
"""Find the indices of cells that intersect a tetrahedron.
Parameters
----------
tetra : (dim+1, dim) array_like
The points of the tetrahedron(s).
Returns
-------
numpy.ndarray of int
The indices of cells which overlap the triangle.
"""
if self.dim == 2:
return self.get_cells_in_triangle(tetra)
tetra = self._require_ndarray_with_dim('tetra', tetra, ndim=2, dtype=np.float64)
if tetra.shape[0] != 4:
raise ValueError(f"A tetrahedron is d
gitextract_xzf28t4b/
├── .ci/
│ ├── azure/
│ │ ├── deploy.yml
│ │ ├── docs.yml
│ │ ├── run_tests.sh
│ │ ├── sdist.yml
│ │ ├── setup_env.sh
│ │ ├── setup_miniconda_macos.sh
│ │ ├── style.yml
│ │ └── test.yml
│ ├── environment_test.yml
│ ├── environment_test_bare.yml
│ ├── install_style.sh
│ ├── parse_style_requirements.py
│ └── setup_headless_display.sh
├── .git_archival.txt
├── .gitattributes
├── .github/
│ └── workflows/
│ └── build_distributions.yml
├── .gitignore
├── .pre-commit-config.yaml
├── AUTHORS.rst
├── CITATION.rst
├── LICENSE
├── README.rst
├── azure-pipelines.yml
├── discretize/
│ ├── Tests/
│ │ ├── __init__.py
│ │ └── meson.build
│ ├── View.py
│ ├── __init__.py
│ ├── _extensions/
│ │ ├── __init__.py
│ │ ├── geom.cpp
│ │ ├── geom.h
│ │ ├── geom.pxd
│ │ ├── interputils_cython.pxd
│ │ ├── interputils_cython.pyx
│ │ ├── meson.build
│ │ ├── simplex_helpers.pyx
│ │ ├── tree.cpp
│ │ ├── tree.h
│ │ ├── tree.pxd
│ │ ├── tree_ext.pyx
│ │ └── triplet.h
│ ├── base/
│ │ ├── __init__.py
│ │ ├── base_mesh.py
│ │ ├── base_regular_mesh.py
│ │ ├── base_tensor_mesh.py
│ │ └── meson.build
│ ├── curvilinear_mesh.py
│ ├── cylindrical_mesh.py
│ ├── meson.build
│ ├── mixins/
│ │ ├── __init__.py
│ │ ├── mesh_io.py
│ │ ├── meson.build
│ │ ├── mpl_mod.py
│ │ ├── omf_mod.py
│ │ └── vtk_mod.py
│ ├── operators/
│ │ ├── __init__.py
│ │ ├── differential_operators.py
│ │ ├── inner_products.py
│ │ └── meson.build
│ ├── tensor_cell.py
│ ├── tensor_mesh.py
│ ├── tests.py
│ ├── tree_mesh.py
│ ├── unstructured_mesh.py
│ └── utils/
│ ├── __init__.py
│ ├── code_utils.py
│ ├── codeutils.py
│ ├── coordinate_utils.py
│ ├── coordutils.py
│ ├── curvilinear_utils.py
│ ├── curvutils.py
│ ├── interpolation_utils.py
│ ├── interputils.py
│ ├── io_utils.py
│ ├── matrix_utils.py
│ ├── matutils.py
│ ├── mesh_utils.py
│ ├── meshutils.py
│ └── meson.build
├── docs/
│ ├── Makefile
│ ├── _static/
│ │ ├── css/
│ │ │ └── custom.css
│ │ └── versions.json
│ ├── _templates/
│ │ └── autosummary/
│ │ ├── attribute.rst
│ │ ├── base.rst
│ │ ├── class.rst
│ │ ├── function.rst
│ │ └── method.rst
│ ├── api/
│ │ ├── discretize.base.rst
│ │ ├── discretize.mixins.rst
│ │ ├── discretize.operators.rst
│ │ ├── discretize.rst
│ │ ├── discretize.tests.rst
│ │ ├── discretize.utils.rst
│ │ └── index.rst
│ ├── conf.py
│ ├── content/
│ │ ├── additional_resources.rst
│ │ ├── big_picture.rst
│ │ ├── finite_volume.rst
│ │ ├── getting_started.rst
│ │ ├── inner_products.rst
│ │ ├── installing.rst
│ │ ├── theory.rst
│ │ └── user_guide.rst
│ ├── index.rst
│ ├── make.bat
│ └── release/
│ ├── 0.10.0-notes.rst
│ ├── 0.11.0-notes.rst
│ ├── 0.11.1-notes.rst
│ ├── 0.11.2-notes.rst
│ ├── 0.11.3-notes.rst
│ ├── 0.12.0-notes.rst
│ ├── 0.4.12-notes.rst
│ ├── 0.4.13-notes.rst
│ ├── 0.4.14-notes.rst
│ ├── 0.4.15-notes.rst
│ ├── 0.5.0-notes.rst
│ ├── 0.5.1-notes.rst
│ ├── 0.6.0-notes.rst
│ ├── 0.6.1-notes.rst
│ ├── 0.6.2-notes.rst
│ ├── 0.6.3-notes.rst
│ ├── 0.7.0-notes.rst
│ ├── 0.7.1-notes.rst
│ ├── 0.7.2-notes.rst
│ ├── 0.7.3-notes.rst
│ ├── 0.7.4-notes.rst
│ ├── 0.8.0-notes.rst
│ ├── 0.8.1-notes.rst
│ ├── 0.8.2-notes.rst
│ ├── 0.8.3-notes.rst
│ ├── 0.9.0-notes.rst
│ └── index.rst
├── examples/
│ ├── README.txt
│ ├── plot_cahn_hilliard.py
│ ├── plot_cyl_mirror.py
│ ├── plot_dc_resistivity.py
│ ├── plot_image.py
│ ├── plot_pyvista_laguna.py
│ ├── plot_quadtree_divergence.py
│ ├── plot_quadtree_hanging.py
│ ├── plot_slicer_demo.py
│ └── plot_streamThickness.py
├── meson.build
├── meson.options
├── pyproject.toml
├── tests/
│ ├── __init__.py
│ ├── base/
│ │ ├── __init__.py
│ │ ├── test_basemesh.py
│ │ ├── test_coordutils.py
│ │ ├── test_curvilinear.py
│ │ ├── test_curvilinear_vtk.py
│ │ ├── test_interpolation.py
│ │ ├── test_operators.py
│ │ ├── test_properties.py
│ │ ├── test_slicer.py
│ │ ├── test_tensor.py
│ │ ├── test_tensor_cell.py
│ │ ├── test_tensor_innerproduct.py
│ │ ├── test_tensor_innerproduct_derivs.py
│ │ ├── test_tensor_io.py
│ │ ├── test_tensor_omf.py
│ │ ├── test_tensor_vtk.py
│ │ ├── test_tests.py
│ │ ├── test_utils.py
│ │ ├── test_view.py
│ │ └── test_volume_avg.py
│ ├── boundaries/
│ │ ├── test_boundary_integrals.py
│ │ ├── test_boundary_maxwell.py
│ │ ├── test_boundary_poisson.py
│ │ ├── test_errors.py
│ │ ├── test_tensor_boundary.py
│ │ └── test_tensor_boundary_poisson.py
│ ├── cyl/
│ │ ├── __init__.py
│ │ ├── test_cyl.py
│ │ ├── test_cyl3D.py
│ │ ├── test_cylOperators.py
│ │ ├── test_cyl_counting.py
│ │ ├── test_cyl_innerproducts.py
│ │ ├── test_cyl_io.py
│ │ └── test_cyl_operators.py
│ ├── simplex/
│ │ ├── __init__.py
│ │ ├── test_inner_products.py
│ │ ├── test_interpolation.py
│ │ ├── test_operators.py
│ │ └── test_utils.py
│ └── tree/
│ ├── __init__.py
│ ├── test_intersections.py
│ ├── test_refine.py
│ ├── test_safeguards.py
│ ├── test_tree.py
│ ├── test_tree_balancing.py
│ ├── test_tree_innerproduct_derivs.py
│ ├── test_tree_interpolation.py
│ ├── test_tree_io.py
│ ├── test_tree_operators.py
│ ├── test_tree_plotting.py
│ ├── test_tree_utils.py
│ └── test_tree_vtk.py
└── tutorials/
├── inner_products/
│ ├── 1_basic.py
│ ├── 2_physical_properties.py
│ ├── 3_calculus.py
│ ├── 4_advanced.py
│ └── README.txt
├── mesh_generation/
│ ├── 1_mesh_overview.py
│ ├── 2_tensor_mesh.py
│ ├── 3_cylindrical_mesh.py
│ ├── 4_tree_mesh.py
│ └── README.txt
├── operators/
│ ├── 1_averaging.py
│ ├── 2_differential.py
│ └── README.txt
└── pde/
├── 1_poisson.py
├── 2_advection_diffusion.py
├── 3_nodal_dirichlet_poisson.py
└── README.txt
SYMBOL INDEX (2009 symbols across 88 files)
FILE: discretize/_extensions/geom.h
type std (line 5) | typedef std::size_t int_t;
function class (line 7) | class Geometric{
function class (line 16) | class Ball : public Geometric{
function class (line 27) | class Line : public Geometric{
function class (line 38) | class Box : public Geometric{
function class (line 48) | class Plane : public Geometric{
function class (line 58) | class Triangle : public Geometric{
function class (line 73) | class VerticalTriangularPrism : public Triangle{
function class (line 82) | class Tetrahedron : public Geometric{
FILE: discretize/_extensions/tree.cpp
function Node (line 138) | Node * set_default_node(node_map_t& nodes, int_t x, int_t y, int_t z,
function Edge (line 149) | Edge * set_default_edge(edge_map_t& edges, Node& p1, Node& p2){
function Face (line 162) | Face * set_default_face(face_map_t& faces, Node& p1, Node& p2, Node& p3,...
function Cell (line 758) | Cell* Cell::containing_cell(double x, double y, double z){
function Cell (line 1499) | Cell* Tree::containing_cell(double x, double y, double z){
FILE: discretize/_extensions/tree.h
type std (line 11) | typedef std::size_t int_t;
function int_t (line 13) | inline int_t key_func(int_t x, int_t y){
function int_t (line 17) | inline int_t key_func(int_t x, int_t y, int_t z){
type PyWrapper (line 26) | typedef PyWrapper* function;
type std (line 28) | typedef std::map<int_t, Node *> node_map_t;
type std (line 29) | typedef std::map<int_t, Edge *> edge_map_t;
type std (line 30) | typedef std::map<int_t, Face *> face_map_t;
type node_map_t (line 31) | typedef node_map_t::iterator node_it_type;
type edge_map_t (line 32) | typedef edge_map_t::iterator edge_it_type;
type face_map_t (line 33) | typedef face_map_t::iterator face_it_type;
type std (line 34) | typedef std::vector<Cell *> cell_vec_t;
type std (line 35) | typedef std::vector<int_t> int_vec_t;
function class (line 37) | class PyWrapper{
function class (line 56) | class Node{
function class (line 72) | class Edge{
function class (line 90) | class Face{
function class (line 109) | class Cell{
function class (line 185) | class Tree{
FILE: discretize/_extensions/triplet.h
function T (line 10) | T v1{}
function U (line 11) | U v2{}
function V (line 12) | V v3{}
function namespace (line 35) | namespace std {
FILE: discretize/base/base_mesh.py
class BaseMesh (line 16) | class BaseMesh:
method __getattr__ (line 43) | def __getattr__(self, name):
method to_dict (line 50) | def to_dict(self):
method equals (line 84) | def equals(self, other_mesh):
method serialize (line 130) | def serialize(self):
method deserialize (line 142) | def deserialize(cls, items, **kwargs):
method save (line 157) | def save(self, file_name="mesh.json", verbose=False, **kwargs):
method copy (line 185) | def copy(self):
method validate (line 199) | def validate(self):
method dim (line 212) | def dim(self):
method n_cells (line 226) | def n_cells(self):
method __len__ (line 240) | def __len__(self):
method n_nodes (line 253) | def n_nodes(self):
method n_edges (line 268) | def n_edges(self):
method n_faces (line 283) | def n_faces(self):
method cell_centers (line 299) | def cell_centers(self):
method nodes (line 339) | def nodes(self):
method boundary_nodes (line 398) | def boundary_nodes(self):
method faces (line 414) | def faces(self):
method boundary_faces (line 476) | def boundary_faces(self):
method edges (line 492) | def edges(self):
method boundary_edges (line 554) | def boundary_edges(self):
method face_normals (line 572) | def face_normals(self):
method edge_tangents (line 591) | def edge_tangents(self):
method boundary_face_outward_normals (line 610) | def boundary_face_outward_normals(self):
method project_face_vector (line 627) | def project_face_vector(self, face_vectors):
method project_edge_vector (line 657) | def project_edge_vector(self, edge_vectors):
method cell_volumes (line 689) | def cell_volumes(self):
method face_areas (line 707) | def face_areas(self):
method edge_lengths (line 727) | def edge_lengths(self):
method face_divergence (line 747) | def face_divergence(self):
method nodal_gradient (line 895) | def nodal_gradient(self):
method edge_curl (line 1035) | def edge_curl(self):
method boundary_face_scalar_integral (line 1189) | def boundary_face_scalar_integral(self):
method boundary_edge_vector_integral (line 1216) | def boundary_edge_vector_integral(self):
method boundary_node_vector_integral (line 1252) | def boundary_node_vector_integral(self):
method nodal_laplacian (line 1282) | def nodal_laplacian(self):
method stencil_cell_gradient (line 1398) | def stencil_cell_gradient(self):
method get_face_inner_product (line 1530) | def get_face_inner_product(
method get_edge_inner_product (line 1707) | def get_edge_inner_product(
method get_edge_inner_product_surface (line 1886) | def get_edge_inner_product_surface(
method get_face_inner_product_surface (line 2009) | def get_face_inner_product_surface(
method get_edge_inner_product_line (line 2158) | def get_edge_inner_product_line(
method get_face_inner_product_deriv (line 2306) | def get_face_inner_product_deriv(
method get_edge_inner_product_deriv (line 2489) | def get_edge_inner_product_deriv(
method get_edge_inner_product_surface_deriv (line 2671) | def get_edge_inner_product_surface_deriv(
method get_face_inner_product_surface_deriv (line 2717) | def get_face_inner_product_surface_deriv(
method get_edge_inner_product_line_deriv (line 2820) | def get_edge_inner_product_line_deriv(
method average_face_to_cell (line 2927) | def average_face_to_cell(self):
method average_face_to_cell_vector (line 3013) | def average_face_to_cell_vector(self):
method average_cell_to_face (line 3114) | def average_cell_to_face(self):
method average_cell_vector_to_face (line 3208) | def average_cell_vector_to_face(self):
method average_cell_to_edge (line 3314) | def average_cell_to_edge(self):
method average_edge_to_cell (line 3407) | def average_edge_to_cell(self):
method average_edge_to_cell_vector (line 3492) | def average_edge_to_cell_vector(self):
method average_edge_to_face (line 3592) | def average_edge_to_face(self):
method average_node_to_cell (line 3680) | def average_node_to_cell(self):
method average_node_to_edge (line 3765) | def average_node_to_edge(self):
method average_node_to_face (line 3851) | def average_node_to_face(self):
method project_face_to_boundary_face (line 3937) | def project_face_to_boundary_face(self):
method project_edge_to_boundary_edge (line 3958) | def project_edge_to_boundary_edge(self):
method project_node_to_boundary_node (line 3979) | def project_node_to_boundary_node(self):
method closest_points_index (line 3999) | def closest_points_index(self, locations, grid_loc="CC", discard=False):
method point2index (line 4066) | def point2index(self, locs):
method get_interpolation_matrix (line 4084) | def get_interpolation_matrix(
method _parse_location_type (line 4182) | def _parse_location_type(self, location_type):
FILE: discretize/base/base_regular_mesh.py
class BaseRegularMesh (line 9) | class BaseRegularMesh(BaseMesh):
method __init__ (line 47) | def __init__(
method origin (line 82) | def origin(self):
method origin (line 100) | def origin(self, value):
method shape_cells (line 111) | def shape_cells(self):
method orientation (line 132) | def orientation(self):
method orientation (line 156) | def orientation(self, value):
method reference_system (line 174) | def reference_system(self):
method reference_system (line 188) | def reference_system(self, value):
method x0 (line 209) | def x0(self):
method x0 (line 219) | def x0(self, val):
method dim (line 223) | def dim(self): # NOQA D102
method n_cells (line 228) | def n_cells(self): # NOQA D102
method n_nodes (line 233) | def n_nodes(self): # NOQA D102
method n_edges_x (line 238) | def n_edges_x(self):
method n_edges_y (line 256) | def n_edges_y(self):
method n_edges_z (line 276) | def n_edges_z(self):
method n_edges_per_direction (line 296) | def n_edges_per_direction(self):
method n_edges (line 328) | def n_edges(self): # NOQA D102
method n_faces_x (line 338) | def n_faces_x(self):
method n_faces_y (line 356) | def n_faces_y(self):
method n_faces_z (line 376) | def n_faces_z(self):
method n_faces_per_direction (line 396) | def n_faces_per_direction(self):
method n_faces (line 428) | def n_faces(self): # NOQA D102
method face_normals (line 438) | def face_normals(self): # NOQA D102
method edge_tangents (line 463) | def edge_tangents(self): # NOQA D102
method reference_is_rotated (line 488) | def reference_is_rotated(self):
method rotation_matrix (line 510) | def rotation_matrix(self):
method axis_u (line 520) | def axis_u(self):
method axis_u (line 533) | def axis_u(self, value):
method axis_v (line 540) | def axis_v(self):
method axis_v (line 553) | def axis_v(self, value):
method axis_w (line 560) | def axis_w(self):
method axis_w (line 573) | def axis_w(self, value):
class BaseRectangularMesh (line 580) | class BaseRectangularMesh(BaseRegularMesh):
method shape_nodes (line 601) | def shape_nodes(self):
method shape_edges_x (line 620) | def shape_edges_x(self):
method shape_edges_y (line 643) | def shape_edges_y(self):
method shape_edges_z (line 669) | def shape_edges_z(self):
method shape_faces_x (line 693) | def shape_faces_x(self):
method shape_faces_y (line 715) | def shape_faces_y(self):
method shape_faces_z (line 741) | def shape_faces_z(self):
method n_cells (line 770) | def n_cells(self): # NOQA D102
method n_nodes (line 775) | def n_nodes(self): # NOQA D102
method n_edges_x (line 780) | def n_edges_x(self): # NOQA D102
method n_edges_y (line 785) | def n_edges_y(self): # NOQA D102
method n_edges_z (line 792) | def n_edges_z(self): # NOQA D102
method n_faces_x (line 799) | def n_faces_x(self): # NOQA D102
method n_faces_y (line 804) | def n_faces_y(self): # NOQA D102
method n_faces_z (line 811) | def n_faces_z(self): # NOQA D102
method reshape (line 817) | def reshape(
method nCx (line 1006) | def nCx(self):
method nCy (line 1018) | def nCy(self):
method nCz (line 1030) | def nCz(self):
method nNx (line 1042) | def nNx(self):
method nNy (line 1054) | def nNy(self):
method nNz (line 1066) | def nNz(self):
FILE: discretize/base/base_tensor_mesh.py
class BaseTensorMesh (line 24) | class BaseTensorMesh(BaseRegularMesh):
method __init__ (line 86) | def __init__(self, h, origin=None, **kwargs):
method h (line 117) | def h(self):
method origin (line 139) | def origin(self, value): # NOQA D102
method nodes_x (line 156) | def nodes_x(self):
method nodes_y (line 177) | def nodes_y(self):
method nodes_z (line 199) | def nodes_z(self):
method cell_centers_x (line 221) | def cell_centers_x(self):
method cell_centers_y (line 243) | def cell_centers_y(self):
method cell_centers_z (line 268) | def cell_centers_z(self):
method cell_centers (line 293) | def cell_centers(self): # NOQA D102
method nodes (line 298) | def nodes(self): # NOQA D102
method boundary_nodes (line 303) | def boundary_nodes(self): # NOQA D102
method h_gridded (line 311) | def h_gridded(self):
method faces_x (line 358) | def faces_x(self):
method faces_y (line 376) | def faces_y(self):
method faces_z (line 394) | def faces_z(self):
method faces (line 412) | def faces(self): # NOQA D102
method boundary_faces (line 425) | def boundary_faces(self): # NOQA D102
method boundary_face_outward_normals (line 441) | def boundary_face_outward_normals(self): # NOQA D102
method edges_x (line 469) | def edges_x(self):
method edges_y (line 487) | def edges_y(self):
method edges_z (line 505) | def edges_z(self):
method edges (line 523) | def edges(self): # NOQA D102
method boundary_edges (line 536) | def boundary_edges(self):
method _getTensorGrid (line 562) | def _getTensorGrid(self, key):
method get_tensor (line 567) | def get_tensor(self, key):
method is_inside (line 638) | def is_inside(self, pts, location_type="nodes", **kwargs):
method _get_interpolation_matrix (line 684) | def _get_interpolation_matrix(
method get_interpolation_matrix (line 776) | def get_interpolation_matrix( # NOQA D102
method _fastInnerProduct (line 792) | def _fastInnerProduct(
method _fastInnerProductDeriv (line 865) | def _fastInnerProductDeriv(
method hx (line 992) | def hx(self):
method hy (line 1004) | def hy(self):
method hz (line 1016) | def hz(self):
FILE: discretize/curvilinear_mesh.py
function _length2D (line 19) | def _length2D(x):
function _length3D (line 23) | def _length3D(x):
function _normalize2D (line 27) | def _normalize2D(x):
function _normalize3D (line 31) | def _normalize3D(x):
class CurvilinearMesh (line 35) | class CurvilinearMesh(
method __init__ (line 98) | def __init__(self, node_list, **kwargs):
method node_list (line 131) | def node_list(self):
method deserialize (line 146) | def deserialize(cls, value, **kwargs): # NOQA D102
method cell_centers (line 153) | def cell_centers(self): # NOQA D102
method nodes (line 162) | def nodes(self): # NOQA D102
method faces_x (line 169) | def faces_x(self):
method faces_y (line 242) | def faces_y(self):
method faces_z (line 315) | def faces_z(self):
method faces (line 343) | def faces(self): # NOQA D102
method edges_x (line 351) | def edges_x(self):
method edges_y (line 412) | def edges_y(self):
method edges_z (line 473) | def edges_z(self):
method edges (line 495) | def edges(self): # NOQA D102
method boundary_nodes (line 503) | def boundary_nodes(self): # NOQA D102
method boundary_edges (line 508) | def boundary_edges(self): # NOQA D102
method boundary_faces (line 521) | def boundary_faces(self): # NOQA D102
method boundary_face_outward_normals (line 532) | def boundary_face_outward_normals(self): # NOQA D102
method cell_volumes (line 590) | def cell_volumes(self): # NOQA D102
method face_areas (line 625) | def face_areas(self): # NOQA D102
method face_normals (line 670) | def face_normals(self): # NOQA D102
method edge_lengths (line 702) | def edge_lengths(self): # NOQA D102
method edge_tangents (line 737) | def edge_tangents(self): # NOQA D102
method _get_edge_surf_int_proj_mats (line 743) | def _get_edge_surf_int_proj_mats(self, only_boundary=False, with_area=...
method boundary_edge_vector_integral (line 813) | def boundary_edge_vector_integral(self): # NOQA D102
FILE: discretize/cylindrical_mesh.py
class CylindricalMesh (line 31) | class CylindricalMesh(
method __init__ (line 134) | def __init__(self, h, origin=None, cartesian_origin=None, **kwargs):
method cartesian_origin (line 151) | def cartesian_origin(self):
method cartesian_origin (line 167) | def cartesian_origin(self, value):
method is_wrapped (line 178) | def is_wrapped(self):
method is_symmetric (line 188) | def is_symmetric(self):
method includes_zero (line 210) | def includes_zero(self):
method shape_nodes (line 220) | def shape_nodes(self):
method _shape_total_nodes (line 247) | def _shape_total_nodes(self):
method n_nodes (line 257) | def n_nodes(self):
method _n_total_nodes (line 280) | def _n_total_nodes(self):
method _shape_total_faces_x (line 284) | def _shape_total_faces_x(self):
method _n_total_faces_x (line 289) | def _n_total_faces_x(self):
method _n_hanging_faces_x (line 294) | def _n_hanging_faces_x(self):
method shape_faces_x (line 302) | def shape_faces_x(self):
method _shape_total_faces_y (line 322) | def _shape_total_faces_y(self):
method _n_total_faces_y (line 328) | def _n_total_faces_y(self):
method _n_hanging_faces_y (line 333) | def _n_hanging_faces_y(self):
method _shape_total_faces_z (line 341) | def _shape_total_faces_z(self):
method _n_total_faces_z (line 346) | def _n_total_faces_z(self):
method _n_hanging_faces_z (line 351) | def _n_hanging_faces_z(self):
method _shape_total_edges_x (line 356) | def _shape_total_edges_x(self):
method _n_total_edges_x (line 361) | def _n_total_edges_x(self):
method _shape_total_edges_y (line 366) | def _shape_total_edges_y(self):
method _n_total_edges_y (line 372) | def _n_total_edges_y(self):
method shape_edges_y (line 377) | def shape_edges_y(self):
method _shape_total_edges_z (line 397) | def _shape_total_edges_z(self):
method _n_total_edges_z (line 402) | def _n_total_edges_z(self):
method shape_edges_z (line 407) | def shape_edges_z(self):
method n_edges_z (line 426) | def n_edges_z(self):
method cell_centers_x (line 451) | def cell_centers_x(self):
method cell_centers_y (line 471) | def cell_centers_y(self):
method nodes_x (line 492) | def nodes_x(self):
method _nodes_y_full (line 510) | def _nodes_y_full(self):
method nodes_y (line 517) | def nodes_y(self):
method _edge_x_lengths_full (line 535) | def _edge_x_lengths_full(self):
method edge_x_lengths (line 541) | def edge_x_lengths(self):
method _edge_y_lengths_full (line 560) | def _edge_y_lengths_full(self):
method edge_y_lengths (line 569) | def edge_y_lengths(self):
method _edge_z_lengths_full (line 595) | def _edge_z_lengths_full(self):
method edge_z_lengths (line 601) | def edge_z_lengths(self):
method _edge_lengths_full (line 619) | def _edge_lengths_full(self):
method edge_lengths (line 631) | def edge_lengths(self):
method _face_x_areas_full (line 653) | def _face_x_areas_full(self):
method face_x_areas (line 660) | def face_x_areas(self):
method _face_y_areas_full (line 685) | def _face_y_areas_full(self):
method face_y_areas (line 692) | def face_y_areas(self):
method _face_z_areas_full (line 718) | def _face_z_areas_full(self):
method face_z_areas (line 734) | def face_z_areas(self):
method _face_areas_full (line 758) | def _face_areas_full(self):
method face_areas (line 765) | def face_areas(self):
method cell_volumes (line 790) | def cell_volumes(self):
method _ishanging_faces_x (line 823) | def _ishanging_faces_x(self):
method _hanging_faces_x (line 833) | def _hanging_faces_x(self):
method _ishanging_faces_y (line 850) | def _ishanging_faces_y(self):
method _hanging_faces_y (line 860) | def _hanging_faces_y(self):
method _ishanging_faces_z (line 878) | def _ishanging_faces_z(self):
method _hanging_faces_z (line 885) | def _hanging_faces_z(self):
method _ishanging_edges_x (line 894) | def _ishanging_edges_x(self):
method _hanging_edges_x (line 904) | def _hanging_edges_x(self):
method _ishanging_edges_y (line 922) | def _ishanging_edges_y(self):
method _hanging_edges_y (line 932) | def _hanging_edges_y(self):
method _ishanging_edges (line 949) | def _ishanging_edges(self):
method _ishanging_edges_z (line 960) | def _ishanging_edges_z(self):
method _hanging_edges_z (line 983) | def _hanging_edges_z(self):
method _ishanging_nodes (line 1010) | def _ishanging_nodes(self):
method _hanging_nodes (line 1028) | def _hanging_nodes(self):
method _nodes_full (line 1060) | def _nodes_full(self):
method nodes (line 1065) | def nodes(self):
method _faces_x_full (line 1085) | def _faces_x_full(self):
method faces_x (line 1090) | def faces_x(self):
method _edges_y_full (line 1112) | def _edges_y_full(self):
method edges_y (line 1117) | def edges_y(self):
method _edges_z_full (line 1139) | def _edges_z_full(self):
method edges_z (line 1144) | def edges_z(self):
method _is_boundary_face (line 1166) | def _is_boundary_face(self):
method boundary_faces (line 1190) | def boundary_faces(self): # NOQA D102
method boundary_face_outward_normals (line 1195) | def boundary_face_outward_normals(self): # NOQA D102
method _is_boundary_node (line 1218) | def _is_boundary_node(self):
method boundary_nodes (line 1233) | def boundary_nodes(self): # NOQA D102
method _is_boundary_edge (line 1238) | def _is_boundary_edge(self):
method boundary_edges (line 1268) | def boundary_edges(self): # NOQA D102
method face_divergence (line 1277) | def face_divergence(self): # NOQA D102
method face_x_divergence (line 1292) | def face_x_divergence(self): # NOQA D102
method face_y_divergence (line 1314) | def face_y_divergence(self): # NOQA D102
method face_z_divergence (line 1329) | def face_z_divergence(self): # NOQA D102
method cell_gradient_x (line 1339) | def cell_gradient_x(self): # NOQA D102
method stencil_cell_gradient_y (line 1353) | def stencil_cell_gradient_y(self): # NOQA D102
method stencil_cell_gradient_z (line 1358) | def stencil_cell_gradient_z(self): # NOQA D102
method stencil_cell_gradient (line 1363) | def stencil_cell_gradient(self): # NOQA D102
method cell_gradient (line 1368) | def cell_gradient(self): # NOQA D102
method nodal_gradient (line 1373) | def nodal_gradient(self): # NOQA D102
method _edge_curl_stencil (line 1415) | def _edge_curl_stencil(self):
method edge_curl (line 1436) | def edge_curl(self): # NOQA D102
method average_edge_x_to_cell (line 1447) | def average_edge_x_to_cell(self): # NOQA D102
method average_edge_y_to_cell (line 1461) | def average_edge_y_to_cell(self): # NOQA D102
method average_edge_z_to_cell (line 1480) | def average_edge_z_to_cell(self): # NOQA D102
method average_edge_to_cell (line 1494) | def average_edge_to_cell(self): # NOQA D102
method average_edge_to_cell_vector (line 1512) | def average_edge_to_cell_vector(self): # NOQA D102
method average_edge_to_face (line 1524) | def average_edge_to_face(self): # NOQA D102
method average_face_x_to_cell (line 1545) | def average_face_x_to_cell(self): # NOQA D102
method average_face_y_to_cell (line 1553) | def average_face_y_to_cell(self): # NOQA D102
method average_face_to_cell (line 1561) | def average_face_to_cell(self): # NOQA D102
method average_face_to_cell_vector (line 1581) | def average_face_to_cell_vector(self): # NOQA D102
method _average_node_to_face_x (line 1596) | def _average_node_to_face_x(self):
method _average_node_to_face_y (line 1605) | def _average_node_to_face_y(self):
method average_node_to_face (line 1614) | def average_node_to_face(self): # NOQA D102
method average_node_to_cell (line 1623) | def average_node_to_cell(self): # NOQA D102
method average_cell_to_face (line 1632) | def average_cell_to_face(self): # NOQA D102
method project_face_to_boundary_face (line 1672) | def project_face_to_boundary_face(self): # NOQA D102
method project_node_to_boundary_node (line 1678) | def project_node_to_boundary_node(self): # NOQA D102
method project_edge_to_boundary_edge (line 1684) | def project_edge_to_boundary_edge(self): # NOQA D102
method _deflation_matrix (line 1693) | def _deflation_matrix(self, location, as_ones=False):
method get_interpolation_matrix (line 1766) | def get_interpolation_matrix(
method cartesian_grid (line 2022) | def cartesian_grid(self, location_type="cell_centers", theta_shift=Non...
method get_interpolation_matrix_cartesian_mesh (line 2053) | def get_interpolation_matrix_cartesian_mesh(
class CylMesh (line 2209) | class CylMesh(CylindricalMesh):
FILE: discretize/mixins/__init__.py
class InterfaceMixins (line 56) | class InterfaceMixins(*AVAILABLE_MIXIN_CLASSES):
FILE: discretize/mixins/mesh_io.py
class TensorMeshIO (line 21) | class TensorMeshIO(InterfaceTensorread_vtk):
method _readUBC_3DMesh (line 33) | def _readUBC_3DMesh(cls, file_name):
method _readUBC_2DMesh (line 78) | def _readUBC_2DMesh(cls, file_name):
method read_UBC (line 137) | def read_UBC(cls, file_name, directory=None):
method _readModelUBC_2D (line 170) | def _readModelUBC_2D(mesh, file_name):
method _readModelUBC_3D (line 204) | def _readModelUBC_3D(mesh, file_name):
method read_model_UBC (line 227) | def read_model_UBC(mesh, file_name, directory=None):
method write_model_UBC (line 253) | def write_model_UBC(mesh, file_name, model, directory=None):
method _writeUBC_3DMesh (line 289) | def _writeUBC_3DMesh(mesh, file_name, comment_lines=""):
method _writeUBC_2DMesh (line 317) | def _writeUBC_2DMesh(mesh, file_name, comment_lines=""):
method write_UBC (line 382) | def write_UBC(mesh, file_name, models=None, directory=None, comment_li...
method readUBC (line 420) | def readUBC(TensorMesh, file_name, directory=""):
class TreeMeshIO (line 444) | class TreeMeshIO(object):
method read_UBC (line 456) | def read_UBC(TreeMesh, file_name, directory=None):
method read_model_UBC (line 507) | def read_model_UBC(mesh, file_name, directory=None):
method write_UBC (line 543) | def write_UBC(mesh, file_name, models=None, directory=None):
method write_model_UBC (line 590) | def write_model_UBC(mesh, file_name, model, directory=None):
method readUBC (line 615) | def readUBC(TreeMesh, file_name, directory=""):
class SimplexMeshIO (line 640) | class SimplexMeshIO(InterfaceSimplexReadVTK):
FILE: discretize/mixins/mpl_mod.py
function load_matplotlib (line 11) | def load_matplotlib():
class InterfaceMPL (line 23) | class InterfaceMPL(object):
method plot_grid (line 33) | def plot_grid(
method plot_image (line 203) | def plot_image(
method plot_slice (line 404) | def plot_slice(
method plot_3d_slicer (line 705) | def plot_3d_slicer(
method __plot_grid_tensor (line 796) | def __plot_grid_tensor(
method __plot_image_tensor (line 1021) | def __plot_image_tensor(
method __plot_image_tensor2D (line 1148) | def __plot_image_tensor2D(
method __plot_slice_tensor (line 1321) | def __plot_slice_tensor(
method __plotCylTensorMesh (line 1421) | def __plotCylTensorMesh(self, plotType, *args, **kwargs):
method __plot_grid_cyl (line 1506) | def __plot_grid_cyl(self, *args, **kwargs):
method __plot_gridThetaSlice (line 1583) | def __plot_gridThetaSlice(self, *args, **kwargs):
method __plot_gridZSlice (line 1589) | def __plot_gridZSlice(self, *args, **kwargs):
method __plot_image_cyl (line 1647) | def __plot_image_cyl(self, *args, **kwargs):
method __plot_grid_curv (line 1651) | def __plot_grid_curv(
method __plot_image_curv (line 1769) | def __plot_image_curv(
method __plot_grid_tree (line 1815) | def __plot_grid_tree(
method __plot_image_tree (line 1994) | def __plot_image_tree(
method __plot_slice_tree (line 2113) | def __plot_slice_tree(
method __plot_grid_simp (line 2235) | def __plot_grid_simp(
method __plot_image_simp (line 2273) | def __plot_image_simp(
class Slicer (line 2364) | class Slicer(object):
method __init__ (line 2432) | def __init__(
method onscroll (line 2713) | def onscroll(self, event):
method update_xy (line 2742) | def update_xy(self):
method update_xz (line 2766) | def update_xz(self):
method update_zy (line 2792) | def update_zy(self):
method _clear_elements (line 2818) | def _clear_elements(self, names):
FILE: discretize/mixins/omf_mod.py
function omf (line 7) | def omf():
function _ravel_data_array (line 14) | def _ravel_data_array(arr, nx, ny, nz):
function _unravel_data_array (line 118) | def _unravel_data_array(arr, nx, ny, nz):
class InterfaceOMF (line 151) | class InterfaceOMF(object):
method _tensor_mesh_to_omf (line 159) | def _tensor_mesh_to_omf(mesh, models=None):
method _tree_mesh_to_omf (line 234) | def _tree_mesh_to_omf(mesh, models=None):
method _curvilinear_mesh_to_omf (line 237) | def _curvilinear_mesh_to_omf(mesh, models=None):
method _cyl_mesh_to_omf (line 240) | def _cyl_mesh_to_omf(mesh, models=None):
method to_omf (line 243) | def to_omf(mesh, models=None):
method _omf_volume_to_tensor (line 278) | def _omf_volume_to_tensor(element):
method from_omf (line 302) | def from_omf(element):
FILE: discretize/mixins/vtk_mod.py
function load_vtk (line 64) | def load_vtk(extra=None):
function assign_cell_data (line 82) | def assign_cell_data(vtkDS, models=None):
class InterfaceVTK (line 110) | class InterfaceVTK(object):
method __tree_mesh_to_vtk (line 191) | def __tree_mesh_to_vtk(mesh, models=None):
method __simplex_mesh_to_vtk (line 255) | def __simplex_mesh_to_vtk(mesh, models=None):
method __create_structured_grid (line 299) | def __create_structured_grid(ptsMat, dims, models=None):
method __get_rotated_nodes (line 321) | def __get_rotated_nodes(mesh):
method __tensor_mesh_to_vtk (line 334) | def __tensor_mesh_to_vtk(mesh, models=None):
method __curvilinear_mesh_to_vtk (line 382) | def __curvilinear_mesh_to_vtk(mesh, models=None):
method __cyl_mesh_to_vtk (line 400) | def __cyl_mesh_to_vtk(mesh, models=None):
method to_vtk (line 581) | def to_vtk(mesh, models=None):
method toVTK (line 628) | def toVTK(mesh, models=None):
method _save_unstructured_grid (line 645) | def _save_unstructured_grid(file_name, vtkUnstructGrid, directory=""):
method _save_structured_grid (line 681) | def _save_structured_grid(file_name, vtkStructGrid, directory=""):
method _save_rectilinear_grid (line 718) | def _save_rectilinear_grid(file_name, vtkRectGrid, directory=""):
method write_vtk (line 753) | def write_vtk(mesh, file_name, models=None, directory=""):
method writeVTK (line 790) | def writeVTK(mesh, file_name, models=None, directory=""):
class InterfaceTensorread_vtk (line 809) | class InterfaceTensorread_vtk(object):
method vtk_to_tensor_mesh (line 817) | def vtk_to_tensor_mesh(TensorMesh, vtrGrid):
method read_vtk (line 869) | def read_vtk(TensorMesh, file_name, directory=""):
method readVTK (line 903) | def readVTK(TensorMesh, file_name, directory=""):
class InterfaceSimplexReadVTK (line 922) | class InterfaceSimplexReadVTK:
method vtk_to_simplex_mesh (line 930) | def vtk_to_simplex_mesh(SimplexMesh, vtuGrid):
method read_vtk (line 981) | def read_vtk(SimplexMesh, file_name, directory=""):
FILE: discretize/operators/differential_operators.py
function _validate_BC (line 21) | def _validate_BC(bc):
function _ddxCellGrad (line 41) | def _ddxCellGrad(n, bc):
function _ddxCellGradBC (line 85) | def _ddxCellGradBC(n, bc):
class DiffOperators (line 134) | class DiffOperators(BaseMesh):
method _face_x_divergence_stencil (line 162) | def _face_x_divergence_stencil(self):
method _face_y_divergence_stencil (line 177) | def _face_y_divergence_stencil(self):
method _face_z_divergence_stencil (line 192) | def _face_z_divergence_stencil(self):
method _face_divergence_stencil (line 205) | def _face_divergence_stencil(self):
method face_divergence (line 226) | def face_divergence(self): # NOQA D102
method face_x_divergence (line 238) | def face_x_divergence(self):
method face_y_divergence (line 350) | def face_y_divergence(self):
method face_z_divergence (line 464) | def face_z_divergence(self):
method _nodal_gradient_x_stencil (line 594) | def _nodal_gradient_x_stencil(self):
method _nodal_gradient_y_stencil (line 609) | def _nodal_gradient_y_stencil(self):
method _nodal_gradient_z_stencil (line 624) | def _nodal_gradient_z_stencil(self):
method _nodal_gradient_stencil (line 637) | def _nodal_gradient_stencil(self):
method nodal_gradient (line 659) | def nodal_gradient(self): # NOQA D102
method _nodal_laplacian_x_stencil (line 667) | def _nodal_laplacian_x_stencil(self):
method _nodal_laplacian_y_stencil (line 684) | def _nodal_laplacian_y_stencil(self):
method _nodal_laplacian_z_stencil (line 704) | def _nodal_laplacian_z_stencil(self):
method _nodal_laplacian_x (line 719) | def _nodal_laplacian_x(self):
method _nodal_laplacian_y (line 729) | def _nodal_laplacian_y(self):
method _nodal_laplacian_z (line 741) | def _nodal_laplacian_z(self):
method nodal_laplacian (line 750) | def nodal_laplacian(self): # NOQA D102
method edge_divergence_weak_form_robin (line 772) | def edge_divergence_weak_form_robin(self, alpha=0.0, beta=1.0, gamma=0...
method set_cell_gradient_BC (line 975) | def set_cell_gradient_BC(self, BC):
method stencil_cell_gradient_x (line 1049) | def stencil_cell_gradient_x(self):
method stencil_cell_gradient_y (line 1183) | def stencil_cell_gradient_y(self):
method stencil_cell_gradient_z (line 1311) | def stencil_cell_gradient_z(self):
method stencil_cell_gradient (line 1413) | def stencil_cell_gradient(self): # NOQA D102
method cell_gradient (line 1446) | def cell_gradient(self):
method cell_gradient_weak_form_robin (line 1597) | def cell_gradient_weak_form_robin(self, alpha=0.0, beta=1.0, gamma=0.0):
method cell_gradient_BC (line 1734) | def cell_gradient_BC(self):
method cell_gradient_x (line 1763) | def cell_gradient_x(self):
method cell_gradient_y (line 1879) | def cell_gradient_y(self):
method cell_gradient_z (line 1996) | def cell_gradient_z(self):
method _edge_x_curl_stencil (line 2092) | def _edge_x_curl_stencil(self):
method _edge_y_curl_stencil (line 2104) | def _edge_y_curl_stencil(self):
method _edge_z_curl_stencil (line 2116) | def _edge_z_curl_stencil(self):
method _edge_curl_stencil (line 2128) | def _edge_curl_stencil(self):
method edge_curl (line 2170) | def edge_curl(self): # NOQA D102
method boundary_face_scalar_integral (line 2184) | def boundary_face_scalar_integral(self): # NOQA D102
method boundary_edge_vector_integral (line 2199) | def boundary_edge_vector_integral(self):
method boundary_node_vector_integral (line 2257) | def boundary_node_vector_integral(self):
method get_BC_projections (line 2303) | def get_BC_projections(self, BC, discretization="CC"):
method get_BC_projections_simple (line 2410) | def get_BC_projections_simple(self, discretization="CC"):
method average_face_to_cell (line 2479) | def average_face_to_cell(self): # NOQA D102
method average_face_to_cell_vector (line 2495) | def average_face_to_cell_vector(self): # NOQA D102
method average_face_x_to_cell (line 2511) | def average_face_x_to_cell(self):
method average_face_y_to_cell (line 2604) | def average_face_y_to_cell(self):
method average_face_z_to_cell (line 2697) | def average_face_z_to_cell(self):
method average_cell_to_face (line 2790) | def average_cell_to_face(self): # NOQA D102
method average_cell_vector_to_face (line 2831) | def average_cell_vector_to_face(self): # NOQA D102
method average_cell_to_edge (line 2868) | def average_cell_to_edge(self): # NOQA D102
method average_edge_to_cell (line 2895) | def average_edge_to_cell(self): # NOQA D102
method average_edge_to_cell_vector (line 2911) | def average_edge_to_cell_vector(self): # NOQA D102
method average_edge_x_to_cell (line 2927) | def average_edge_x_to_cell(self):
method average_edge_y_to_cell (line 3020) | def average_edge_y_to_cell(self):
method average_edge_z_to_cell (line 3113) | def average_edge_z_to_cell(self):
method average_edge_to_face (line 3206) | def average_edge_to_face(self): # NOQA D102
method average_node_to_cell (line 3237) | def average_node_to_cell(self): # NOQA D102
method _average_node_to_edge_x (line 3256) | def _average_node_to_edge_x(self):
method _average_node_to_edge_y (line 3271) | def _average_node_to_edge_y(self):
method _average_node_to_edge_z (line 3286) | def _average_node_to_edge_z(self):
method average_node_to_edge (line 3299) | def average_node_to_edge(self): # NOQA D102
method _average_node_to_face_x (line 3322) | def _average_node_to_face_x(self):
method _average_node_to_face_y (line 3336) | def _average_node_to_face_y(self):
method _average_node_to_face_z (line 3350) | def _average_node_to_face_z(self):
method average_node_to_face (line 3362) | def average_node_to_face(self): # NOQA D102
method project_face_to_boundary_face (line 3385) | def project_face_to_boundary_face(self): # NOQA D102
method project_edge_to_boundary_edge (line 3400) | def project_edge_to_boundary_edge(self): # NOQA D102
method project_node_to_boundary_node (line 3419) | def project_node_to_boundary_node(self): # NOQA D102
FILE: discretize/operators/inner_products.py
class InnerProducts (line 23) | class InnerProducts(BaseMesh):
method get_face_inner_product (line 35) | def get_face_inner_product( # NOQA D102
method get_edge_inner_product (line 69) | def get_edge_inner_product( # NOQA D102
method get_edge_inner_product_surface (line 101) | def get_edge_inner_product_surface( # NOQA D102
method _getInnerProduct (line 147) | def _getInnerProduct(
method _getInnerProductProjectionMatrices (line 221) | def _getInnerProductProjectionMatrices(self, projection_type, tensorTy...
method get_face_inner_product_deriv (line 274) | def get_face_inner_product_deriv( # NOQA D102
method get_edge_inner_product_deriv (line 301) | def get_edge_inner_product_deriv( # NOQA D102
method get_edge_inner_product_surface_deriv (line 328) | def get_edge_inner_product_surface_deriv( # NOQA D102
method _getInnerProductDeriv (line 405) | def _getInnerProductDeriv(
method _getInnerProductDerivFunction (line 459) | def _getInnerProductDerivFunction(self, tensorType, P, projection_type...
method _getFacePx (line 586) | def _getFacePx(M):
method _getFacePxx (line 599) | def _getFacePxx(M):
method _getFacePxxx (line 671) | def _getFacePxxx(M):
method _getEdgePx (line 740) | def _getEdgePx(M):
method _getEdgePxx (line 750) | def _getEdgePxx(M):
method _getEdgePxxx (line 792) | def _getEdgePxxx(M):
FILE: discretize/tensor_cell.py
class TensorCell (line 7) | class TensorCell:
method __init__ (line 70) | def __init__(self, h, origin, index_unraveled, mesh_shape):
method __repr__ (line 76) | def __repr__(self):
method __eq__ (line 86) | def __eq__(self, other):
method h (line 102) | def h(self):
method origin (line 107) | def origin(self):
method index (line 112) | def index(self):
method index_unraveled (line 119) | def index_unraveled(self):
method mesh_shape (line 124) | def mesh_shape(self):
method dim (line 129) | def dim(self):
method center (line 134) | def center(self):
method bounds (line 147) | def bounds(self):
method neighbors (line 169) | def neighbors(self):
method nodes (line 189) | def nodes(self):
method edges (line 213) | def edges(self):
method faces (line 309) | def faces(self):
method get_neighbors (line 403) | def get_neighbors(self, mesh):
FILE: discretize/tensor_mesh.py
class TensorMesh (line 15) | class TensorMesh(
method __repr__ (line 97) | def __repr__(self):
method _repr_html_ (line 121) | def _repr_html_(self):
method __iter__ (line 166) | def __iter__(self):
method __getitem__ (line 171) | def __getitem__(self, indices):
method _sanitize_indices (line 228) | def _sanitize_indices(self, indices, dim=None):
method _get_cell (line 261) | def _get_cell(self, indices):
method cell_volumes (line 297) | def cell_volumes(self): # NOQA D102
method face_x_areas (line 313) | def face_x_areas(self):
method face_y_areas (line 344) | def face_y_areas(self):
method face_z_areas (line 376) | def face_z_areas(self):
method face_areas (line 406) | def face_areas(self): # NOQA D102
method edge_x_lengths (line 416) | def edge_x_lengths(self):
method edge_y_lengths (line 445) | def edge_y_lengths(self):
method edge_z_lengths (line 478) | def edge_z_lengths(self):
method edge_lengths (line 509) | def edge_lengths(self): # NOQA D102
method face_boundary_indices (line 520) | def face_boundary_indices(self):
method cell_bounds (line 597) | def cell_bounds(self):
method cell_nodes (line 617) | def cell_nodes(self):
method cell_boundary_indices (line 684) | def cell_boundary_indices(self):
method point2index (line 759) | def point2index(self, locs): # NOQA D102
method _repr_attributes (line 786) | def _repr_attributes(self):
function _slice_to_index (line 852) | def _slice_to_index(index_slice, end):
FILE: discretize/tests.py
function _warn_random_test (line 86) | def _warn_random_test():
function setup_mesh (line 103) | def setup_mesh(mesh_type, nC, nDim, random_seed=None):
class OrderTest (line 234) | class OrderTest(unittest.TestCase):
method setupMesh (line 337) | def setupMesh(self, nC):
method getError (line 356) | def getError(self):
method orderTest (line 371) | def orderTest(self, random_seed=None):
function assert_expected_order (line 417) | def assert_expected_order(
function rosenbrock (line 543) | def rosenbrock(x, return_g=True, return_H=True):
function check_derivative (line 581) | def check_derivative(
function get_quadratic (line 769) | def get_quadratic(A, b, c=0):
function assert_isadjoint (line 814) | def assert_isadjoint(
function assert_cell_intersects_geometric (line 936) | def assert_cell_intersects_geometric(
FILE: discretize/tree_mesh.py
class TreeMesh (line 106) | class TreeMesh(
method __init__ (line 242) | def __init__(self, h=None, origin=None, diagonal_balance=None, **kwargs):
method __repr__ (line 272) | def __repr__(self):
method _repr_html_ (line 324) | def _repr_html_(self):
method origin (line 437) | def origin(self, value): # NOQA D102
method refine_bounding_box (line 443) | def refine_bounding_box(
method refine_points (line 548) | def refine_points(
method refine_surface (line 638) | def refine_surface(
method total_nodes (line 801) | def total_nodes(self):
method vntF (line 817) | def vntF(self):
method vntE (line 832) | def vntE(self):
method stencil_cell_gradient (line 847) | def stencil_cell_gradient(self): # NOQA D102
method cell_gradient (line 861) | def cell_gradient(self): # NOQA D102
method cell_gradient_x (line 895) | def cell_gradient_x(self): # NOQA D102
method cell_gradient_y (line 916) | def cell_gradient_y(self): # NOQA D102
method cell_gradient_z (line 938) | def cell_gradient_z(self): # NOQA D102
method face_x_divergence (line 962) | def face_x_divergence(self): # NOQA D102
method face_y_divergence (line 969) | def face_y_divergence(self): # NOQA D102
method face_z_divergence (line 978) | def face_z_divergence(self): # NOQA D102
method point2index (line 984) | def point2index(self, locs): # NOQA D102
method cell_levels_by_index (line 988) | def cell_levels_by_index(self, indices):
method get_interpolation_matrix (line 1003) | def get_interpolation_matrix( # NOQA D102
method permute_cells (line 1037) | def permute_cells(self):
method permute_faces (line 1049) | def permute_faces(self):
method permute_edges (line 1067) | def permute_edges(self):
method cell_state (line 1085) | def cell_state(self):
method validate (line 1102) | def validate(self): # NOQA D102
method equals (line 1106) | def equals(self, other): # NOQA D102
method __reduce__ (line 1115) | def __reduce__(self):
FILE: discretize/unstructured_mesh.py
class SimplexMesh (line 17) | class SimplexMesh(BaseMesh, SimplexMeshIO, InterfaceMixins):
method __init__ (line 73) | def __init__(self, nodes, simplices):
method _number (line 100) | def _number(self):
method simplices (line 112) | def simplices(self):
method neighbors (line 125) | def neighbors(self):
method transform_and_shift (line 145) | def transform_and_shift(self):
method dim (line 168) | def dim(self): # NOQA D102
method n_nodes (line 173) | def n_nodes(self): # NOQA D102
method nodes (line 178) | def nodes(self): # NOQA D102
method n_cells (line 183) | def n_cells(self): # NOQA D102
method cell_centers (line 188) | def cell_centers(self): # NOQA D102
method cell_volumes (line 195) | def cell_volumes(self): # NOQA D102
method n_edges (line 206) | def n_edges(self): # NOQA D102
method edges (line 211) | def edges(self): # NOQA D102
method edge_tangents (line 218) | def edge_tangents(self): # NOQA D102
method edge_lengths (line 227) | def edge_lengths(self): # NOQA D102
method n_faces (line 236) | def n_faces(self): # NOQA D102
method faces (line 241) | def faces(self): # NOQA D102
method face_areas (line 248) | def face_areas(self): # NOQA D102
method face_normals (line 261) | def face_normals(self): # NOQA D102
method face_divergence (line 280) | def face_divergence(self): # NOQA D102
method nodal_gradient (line 302) | def nodal_gradient(self): # NOQA D102
method edge_curl (line 314) | def edge_curl(self): # NOQA D102
method __validate_model (line 367) | def __validate_model(self, model, invert_model=False):
method __get_inner_product_projection_matrices (line 403) | def __get_inner_product_projection_matrices(
method __get_inner_product (line 467) | def __get_inner_product(self, i_type, model, invert_model):
method get_face_inner_product (line 495) | def get_face_inner_product( # NOQA D102
method get_edge_inner_product (line 509) | def get_edge_inner_product( # NOQA D102
method __get_inner_product_deriv_func (line 523) | def __get_inner_product_deriv_func(self, i_type, model):
method get_face_inner_product_deriv (line 590) | def get_face_inner_product_deriv( # NOQA D102
method get_edge_inner_product_deriv (line 602) | def get_edge_inner_product_deriv( # NOQA D102
method _get_edge_surf_int_proj_mats (line 614) | def _get_edge_surf_int_proj_mats(self, only_boundary=False, with_area=...
method cell_centers_tree (line 684) | def cell_centers_tree(self):
method point2index (line 695) | def point2index(self, locs): # NOQA D102
method get_interpolation_matrix (line 715) | def get_interpolation_matrix( # NOQA D102
method average_node_to_cell (line 894) | def average_node_to_cell(self): # NOQA D102
method average_node_to_face (line 909) | def average_node_to_face(self): # NOQA D102
method average_node_to_edge (line 924) | def average_node_to_edge(self): # NOQA D102
method average_cell_to_node (line 938) | def average_cell_to_node(self):
method average_cell_to_edge (line 966) | def average_cell_to_edge(self): # NOQA D102
method average_face_to_cell_vector (line 987) | def average_face_to_cell_vector(self): # NOQA D102
method average_edge_to_cell_vector (line 1010) | def average_edge_to_cell_vector(self): # NOQA D102
method average_face_to_cell (line 1032) | def average_face_to_cell(self): # NOQA D102
method average_edge_to_cell (line 1049) | def average_edge_to_cell(self): # NOQA D102
method average_edge_to_face (line 1066) | def average_edge_to_face(self): # NOQA D102
method average_cell_to_face (line 1087) | def average_cell_to_face(self): # NOQA D102
method stencil_cell_gradient (line 1098) | def stencil_cell_gradient(self): # NOQA D102
method boundary_face_list (line 1118) | def boundary_face_list(self):
method project_face_to_boundary_face (line 1131) | def project_face_to_boundary_face(self): # NOQA D102
method project_edge_to_boundary_edge (line 1136) | def project_edge_to_boundary_edge(self): # NOQA D102
method project_node_to_boundary_node (line 1144) | def project_node_to_boundary_node(self): # NOQA D102
method boundary_nodes (line 1150) | def boundary_nodes(self): # NOQA D102
method boundary_edges (line 1156) | def boundary_edges(self): # NOQA D102
method boundary_faces (line 1164) | def boundary_faces(self): # NOQA D102
method boundary_face_outward_normals (line 1169) | def boundary_face_outward_normals(self): # NOQA D102
method boundary_face_scalar_integral (line 1182) | def boundary_face_scalar_integral(self): # NOQA D102
method boundary_node_vector_integral (line 1193) | def boundary_node_vector_integral(self): # NOQA D102
method boundary_edge_vector_integral (line 1212) | def boundary_edge_vector_integral(self): # NOQA D102
method __reduce__ (line 1250) | def __reduce__(self):
FILE: discretize/utils/code_utils.py
function is_scalar (line 9) | def is_scalar(f):
function as_array_n_by_dim (line 37) | def as_array_n_by_dim(pts, dim):
function requires (line 76) | def requires(modules):
function deprecate_class (line 118) | def deprecate_class(
function deprecate_module (line 171) | def deprecate_module(
function deprecate_property (line 207) | def deprecate_property(
function deprecate_method (line 272) | def deprecate_method(
function deprecate_function (line 330) | def deprecate_function(
FILE: discretize/utils/coordinate_utils.py
function cylindrical_to_cartesian (line 8) | def cylindrical_to_cartesian(grid, vec=None):
function cyl2cart (line 93) | def cyl2cart(grid, vec=None):
function cartesian_to_cylindrical (line 105) | def cartesian_to_cylindrical(grid, vec=None):
function cart2cyl (line 181) | def cart2cyl(grid, vec=None):
function rotation_matrix_from_normals (line 193) | def rotation_matrix_from_normals(v0, v1, tol=1e-20):
function rotate_points_from_normals (line 256) | def rotate_points_from_normals(xyz, v0, v1, x0=np.r_[0.0, 0.0, 0.0]):
FILE: discretize/utils/curvilinear_utils.py
function example_curvilinear_grid (line 8) | def example_curvilinear_grid(nC, exType):
function volume_tetrahedron (line 78) | def volume_tetrahedron(xyz, A, B, C, D):
function index_cube (line 166) | def index_cube(nodes, grid_shape, n=None):
function face_info (line 303) | def face_info(xyz, A, B, C, D, average=True, normalize_normals=True, **k...
FILE: discretize/utils/interpolation_utils.py
function interpolation_matrix (line 44) | def interpolation_matrix(locs, x, y=None, z=None):
function volume_average (line 175) | def volume_average(mesh_in, mesh_out, values=None, output=None):
FILE: discretize/utils/io_utils.py
function load_mesh (line 9) | def load_mesh(file_name):
function download (line 43) | def download(url, folder=".", overwrite=False, verbose=True):
FILE: discretize/utils/matrix_utils.py
function mkvc (line 9) | def mkvc(x, n_dims=1, **kwargs):
function sdiag (line 85) | def sdiag(v):
function sdinv (line 117) | def sdinv(M):
function speye (line 147) | def speye(n):
function kron3 (line 163) | def kron3(A, B, C):
function spzeros (line 182) | def spzeros(n1, n2):
function ddx (line 200) | def ddx(n):
function av (line 227) | def av(n):
function av_extrap (line 256) | def av_extrap(n):
function ndgrid (line 290) | def ndgrid(*args, vector=True, order="F"):
function make_boundary_bool (line 383) | def make_boundary_bool(shape, bdir="xyz", **kwargs):
function ind2sub (line 464) | def ind2sub(shape, inds):
function sub2ind (line 496) | def sub2ind(shape, subs):
function get_subarray (line 547) | def get_subarray(A, ind):
function inverse_3x3_block_diagonal (line 607) | def inverse_3x3_block_diagonal(
function inverse_2x2_block_diagonal (line 767) | def inverse_2x2_block_diagonal(a11, a12, a21, a22, return_matrix=True, *...
function invert_blocks (line 898) | def invert_blocks(A):
class TensorType (line 982) | class TensorType(object):
method __init__ (line 1047) | def __init__(self, mesh, tensor):
method __str__ (line 1070) | def __str__(self):
method __eq__ (line 1074) | def __eq__(self, v):
method __le__ (line 1078) | def __le__(self, v):
method __ge__ (line 1082) | def __ge__(self, v):
method __lt__ (line 1086) | def __lt__(self, v):
method __gt__ (line 1090) | def __gt__(self, v):
function make_property_tensor (line 1095) | def make_property_tensor(mesh, tensor):
function inverse_property_tensor (line 1246) | def inverse_property_tensor(mesh, tensor, return_matrix=False, **kwargs):
function cross2d (line 1437) | def cross2d(x, y):
class Zero (line 1462) | class Zero(object):
method __repr__ (line 1492) | def __repr__(self):
method __bool__ (line 1496) | def __bool__(self):
method __add__ (line 1500) | def __add__(self, v):
method __radd__ (line 1504) | def __radd__(self, v):
method __iadd__ (line 1508) | def __iadd__(self, v):
method __sub__ (line 1512) | def __sub__(self, v):
method __rsub__ (line 1516) | def __rsub__(self, v):
method __isub__ (line 1520) | def __isub__(self, v):
method __mul__ (line 1524) | def __mul__(self, v):
method __rmul__ (line 1528) | def __rmul__(self, v):
method __matmul__ (line 1532) | def __matmul__(self, v):
method __rmatmul__ (line 1536) | def __rmatmul__(self, v):
method __div__ (line 1540) | def __div__(self, v):
method __truediv__ (line 1544) | def __truediv__(self, v):
method __rdiv__ (line 1548) | def __rdiv__(self, v):
method __rtruediv__ (line 1552) | def __rtruediv__(self, v):
method __rfloordiv__ (line 1556) | def __rfloordiv__(self, v):
method __pos__ (line 1560) | def __pos__(self):
method __neg__ (line 1564) | def __neg__(self):
method __lt__ (line 1568) | def __lt__(self, v):
method __le__ (line 1572) | def __le__(self, v):
method __eq__ (line 1576) | def __eq__(self, v):
method __ne__ (line 1580) | def __ne__(self, v):
method __ge__ (line 1584) | def __ge__(self, v):
method __gt__ (line 1588) | def __gt__(self, v):
method transpose (line 1592) | def transpose(self):
method __getitem__ (line 1596) | def __getitem__(self, key):
method ndim (line 1601) | def ndim(self):
method shape (line 1606) | def shape(self):
method T (line 1611) | def T(self):
class Identity (line 1616) | class Identity(object):
method __init__ (line 1652) | def __init__(self, positive=True):
method __repr__ (line 1655) | def __repr__(self):
method __bool__ (line 1662) | def __bool__(self):
method __pos__ (line 1666) | def __pos__(self):
method __neg__ (line 1670) | def __neg__(self):
method __add__ (line 1674) | def __add__(self, v):
method __radd__ (line 1680) | def __radd__(self, v):
method __sub__ (line 1684) | def __sub__(self, v):
method __rsub__ (line 1688) | def __rsub__(self, v):
method __mul__ (line 1692) | def __mul__(self, v):
method __rmul__ (line 1696) | def __rmul__(self, v):
method __matmul__ (line 1700) | def __matmul__(self, v):
method __rmatmul__ (line 1704) | def __rmatmul__(self, v):
method __div__ (line 1708) | def __div__(self, v):
method __truediv__ (line 1714) | def __truediv__(self, v):
method __rdiv__ (line 1720) | def __rdiv__(self, v):
method __rtruediv__ (line 1724) | def __rtruediv__(self, v):
method __floordiv__ (line 1728) | def __floordiv__(self, v):
method __rfloordiv__ (line 1732) | def __rfloordiv__(self, v):
method __lt__ (line 1736) | def __lt__(self, v):
method __le__ (line 1740) | def __le__(self, v):
method __eq__ (line 1744) | def __eq__(self, v):
method __ne__ (line 1748) | def __ne__(self, v):
method __ge__ (line 1752) | def __ge__(self, v):
method __gt__ (line 1756) | def __gt__(self, v):
method ndim (line 1761) | def ndim(self):
method shape (line 1766) | def shape(self):
method T (line 1771) | def T(self):
method transpose (line 1775) | def transpose(self):
class _inftup (line 1780) | class _inftup(tuple):
method __init__ (line 1783) | def __init__(self, val=None):
method __getitem__ (line 1786) | def __getitem__(self, key):
method __len__ (line 1791) | def __len__(self):
method __repr__ (line 1794) | def __repr__(self):
FILE: discretize/utils/mesh_utils.py
function random_model (line 17) | def random_model(
function unpack_widths (line 117) | def unpack_widths(value):
function closest_points_index (line 189) | def closest_points_index(mesh, pts, grid_loc="CC", **kwargs):
function extract_core_mesh (line 255) | def extract_core_mesh(xyzlim, mesh, mesh_type="tensor"):
function mesh_builder_xyz (line 396) | def mesh_builder_xyz(
function refine_tree_xyz (line 567) | def refine_tree_xyz(
function active_from_xyz (line 940) | def active_from_xyz(mesh, xyz, grid_reference="CC", method="linear"):
function example_simplex_mesh (line 1114) | def example_simplex_mesh(rect_shape):
FILE: docs/conf.py
function linkcode_resolve (line 158) | def linkcode_resolve(domain, info):
FILE: examples/plot_cahn_hilliard.py
function run (line 52) | def run(plotIt=True, n=60):
FILE: examples/plot_cyl_mirror.py
function run (line 14) | def run(plotIt=True):
FILE: examples/plot_dc_resistivity.py
function run (line 14) | def run(plotIt=True):
FILE: examples/plot_image.py
function run (line 12) | def run(plotIt=True):
FILE: examples/plot_quadtree_divergence.py
function run (line 19) | def run(plotIt=True, n=60):
FILE: examples/plot_quadtree_hanging.py
function run (line 18) | def run(plotIt=True):
FILE: examples/plot_slicer_demo.py
function beautify (line 63) | def beautify(title, fig=None):
FILE: tests/base/test_basemesh.py
class TestBaseMesh (line 7) | class TestBaseMesh(unittest.TestCase):
method setUp (line 65) | def setUp(self):
method test_not_impl_attr (line 68) | def test_not_impl_attr(self):
method test_not_impl_func (line 73) | def test_not_impl_func(self):
class TestBaseRectangularMesh (line 96) | class TestBaseRectangularMesh(unittest.TestCase):
method setUp (line 97) | def setUp(self):
method test_meshDimensions (line 100) | def test_meshDimensions(self):
method test_mesh_nc (line 103) | def test_mesh_nc(self):
method test_mesh_nc_xyz (line 107) | def test_mesh_nc_xyz(self):
method test_mesh_nf (line 112) | def test_mesh_nf(self):
method test_mesh_ne (line 117) | def test_mesh_ne(self):
method test_mesh_numbers (line 122) | def test_mesh_numbers(self):
method test_mesh_r_E_V (line 129) | def test_mesh_r_E_V(self):
method test_mesh_r_F_V (line 145) | def test_mesh_r_F_V(self):
method test_mesh_r_E_M (line 161) | def test_mesh_r_E_M(self):
method test_mesh_r_F_M (line 173) | def test_mesh_r_F_M(self):
method test_mesh_r_CC_M (line 185) | def test_mesh_r_CC_M(self):
method test_serialization (line 197) | def test_serialization(self):
class TestMeshNumbers2D (line 204) | class TestMeshNumbers2D(unittest.TestCase):
method setUp (line 205) | def setUp(self):
method test_meshDimensions (line 208) | def test_meshDimensions(self):
method test_mesh_nc (line 211) | def test_mesh_nc(self):
method test_mesh_nc_xyz (line 214) | def test_mesh_nc_xyz(self):
method test_mesh_nf (line 218) | def test_mesh_nf(self):
method test_mesh_ne (line 223) | def test_mesh_ne(self):
method test_mesh_numbers (line 228) | def test_mesh_numbers(self):
method test_mesh_r_E_V (line 239) | def test_mesh_r_E_V(self):
method test_mesh_r_F_V (line 253) | def test_mesh_r_F_V(self):
method test_mesh_r_E_M (line 267) | def test_mesh_r_E_M(self):
method test_mesh_r_F_M (line 276) | def test_mesh_r_F_M(self):
method test_mesh_r_CC_M (line 285) | def test_mesh_r_CC_M(self):
FILE: tests/base/test_coordutils.py
class coorutilsTest (line 10) | class coorutilsTest(unittest.TestCase):
method test_rotation_matrix_from_normals (line 11) | def test_rotation_matrix_from_normals(self):
method test_rotate_points_from_normals (line 25) | def test_rotate_points_from_normals(self):
method test_rotateMatrixFromNormals (line 37) | def test_rotateMatrixFromNormals(self):
method test_rotate_vec_cyl2cart (line 57) | def test_rotate_vec_cyl2cart(self):
FILE: tests/base/test_curvilinear.py
class BasicCurvTests (line 7) | class BasicCurvTests(unittest.TestCase):
method setUp (line 8) | def setUp(self):
method test_area_3D (line 23) | def test_area_3D(self):
method test_vol_3D (line 82) | def test_vol_3D(self):
method test_vol_2D (line 87) | def test_vol_2D(self):
method test_edge_3D (line 92) | def test_edge_3D(self):
method test_edge_2D (line 175) | def test_edge_2D(self):
method test_tangents (line 180) | def test_tangents(self):
method test_normals (line 226) | def test_normals(self):
method test_grid (line 272) | def test_grid(self):
FILE: tests/base/test_curvilinear_vtk.py
class TestCurvilinearMeshVTK (line 16) | class TestCurvilinearMeshVTK(unittest.TestCase):
method setUp (line 17) | def setUp(self):
method test_VTK_object_conversion (line 24) | def test_VTK_object_conversion(self):
method test_VTK_file_IO (line 49) | def test_VTK_file_IO(self):
FILE: tests/base/test_interpolation.py
class TestInterpolation1D (line 43) | class TestInterpolation1D(discretize.tests.OrderTest):
method getError (line 52) | def getError(self):
method test_orderCC (line 67) | def test_orderCC(self):
method test_orderN (line 72) | def test_orderN(self):
class TestOutliersInterp1D (line 78) | class TestOutliersInterp1D(unittest.TestCase):
method setUp (line 79) | def setUp(self):
method test_outliers (line 82) | def test_outliers(self):
class TestInterpolation2d (line 95) | class TestInterpolation2d(discretize.tests.OrderTest):
method getError (line 104) | def getError(self):
method test_orderCC (line 131) | def test_orderCC(self):
method test_orderN (line 136) | def test_orderN(self):
method test_orderFx (line 141) | def test_orderFx(self):
method test_orderFy (line 146) | def test_orderFy(self):
method test_orderEx (line 151) | def test_orderEx(self):
method test_orderEy (line 156) | def test_orderEy(self):
class TestInterpolationSymmetricCyl_Simple (line 162) | class TestInterpolationSymmetricCyl_Simple(unittest.TestCase):
method test_simpleInter (line 163) | def test_simpleInter(self):
method test_exceptions (line 171) | def test_exceptions(self):
class TestInterpolationSymCyl (line 179) | class TestInterpolationSymCyl(discretize.tests.OrderTest):
method getError (line 192) | def getError(self):
method test_orderCC (line 227) | def test_orderCC(self):
method test_orderFx (line 232) | def test_orderFx(self):
method test_orderFz (line 237) | def test_orderFz(self):
method test_orderEy (line 242) | def test_orderEy(self):
class TestInterpolationCyl (line 248) | class TestInterpolationCyl(discretize.tests.OrderTest):
method getError (line 260) | def getError(self):
method test_orderCC (line 279) | def test_orderCC(self):
method test_orderN (line 284) | def test_orderN(self):
method test_orderFx (line 289) | def test_orderFx(self):
method test_orderFy (line 294) | def test_orderFy(self):
method test_orderFz (line 299) | def test_orderFz(self):
method test_orderEx (line 304) | def test_orderEx(self):
method test_orderEy (line 309) | def test_orderEy(self):
method test_orderEz (line 314) | def test_orderEz(self):
class TestInterpolation3D (line 320) | class TestInterpolation3D(discretize.tests.OrderTest):
method getError (line 329) | def getError(self):
method test_orderCC (line 359) | def test_orderCC(self):
method test_orderN (line 364) | def test_orderN(self):
method test_orderFx (line 369) | def test_orderFx(self):
method test_orderFy (line 374) | def test_orderFy(self):
method test_orderFz (line 379) | def test_orderFz(self):
method test_orderEx (line 384) | def test_orderEx(self):
method test_orderEy (line 389) | def test_orderEy(self):
method test_orderEz (line 394) | def test_orderEz(self):
FILE: tests/base/test_operators.py
class TestCurl (line 45) | class TestCurl(discretize.tests.OrderTest):
method getError (line 49) | def getError(self):
method test_order (line 76) | def test_order(self):
class TestCurl2D (line 80) | class TestCurl2D(discretize.tests.OrderTest):
method getError (line 86) | def getError(self):
method test_order (line 99) | def test_order(self):
class TestCellGrad2D_Dirichlet (line 133) | class TestCellGrad2D_Dirichlet(discretize.tests.OrderTest):
method getError (line 139) | def getError(self):
method test_order (line 157) | def test_order(self):
class TestCellGrad3D_Dirichlet (line 161) | class TestCellGrad3D_Dirichlet(discretize.tests.OrderTest):
method getError (line 167) | def getError(self):
method test_order (line 208) | def test_order(self):
class TestCellGrad2D_Neumann (line 212) | class TestCellGrad2D_Neumann(discretize.tests.OrderTest):
method getError (line 218) | def getError(self):
method test_order (line 236) | def test_order(self):
class TestCellGrad3D_Neumann (line 240) | class TestCellGrad3D_Neumann(discretize.tests.OrderTest):
method getError (line 246) | def getError(self):
method test_order (line 287) | def test_order(self):
class TestFaceDiv3D (line 291) | class TestFaceDiv3D(discretize.tests.OrderTest):
method getError (line 296) | def getError(self):
method test_order (line 321) | def test_order(self):
class TestFaceDiv2D (line 325) | class TestFaceDiv2D(discretize.tests.OrderTest):
method getError (line 331) | def getError(self):
method test_order (line 347) | def test_order(self):
class TestNodalGrad (line 351) | class TestNodalGrad(discretize.tests.OrderTest):
method getError (line 355) | def getError(self):
method test_order (line 373) | def test_order(self):
class TestNodalGrad2D (line 377) | class TestNodalGrad2D(discretize.tests.OrderTest):
method getError (line 382) | def getError(self):
method test_order (line 399) | def test_order(self):
class TestAveraging1D (line 403) | class TestAveraging1D(discretize.tests.OrderTest):
method getError (line 409) | def getError(self):
method test_orderN2CC (line 414) | def test_orderN2CC(self):
method test_exactN2F (line 422) | def test_exactN2F(self):
method test_orderN2E (line 430) | def test_orderN2E(self):
method test_orderF2CC (line 438) | def test_orderF2CC(self):
method test_orderF2CCV (line 446) | def test_orderF2CCV(self):
method test_orderCC2F (line 454) | def test_orderCC2F(self):
method test_exactE2CC (line 464) | def test_exactE2CC(self):
method test_exactE2CCV (line 472) | def test_exactE2CCV(self):
method test_exactCC2E (line 480) | def test_exactCC2E(self):
method test_orderCC2FV (line 488) | def test_orderCC2FV(self):
method test_orderE2FV (line 498) | def test_orderE2FV(self):
class TestAverating2DSimple (line 507) | class TestAverating2DSimple(unittest.TestCase):
method setUp (line 508) | def setUp(self):
method test_constantEdges (line 513) | def test_constantEdges(self):
method test_constantFaces (line 518) | def test_constantFaces(self):
class TestAveraging2D (line 524) | class TestAveraging2D(discretize.tests.OrderTest):
method getError (line 530) | def getError(self):
method test_orderN2CC (line 535) | def test_orderN2CC(self):
method test_orderN2F (line 543) | def test_orderN2F(self):
method test_orderN2E (line 551) | def test_orderN2E(self):
method test_orderF2CC (line 559) | def test_orderF2CC(self):
method test_orderF2CCV (line 567) | def test_orderF2CCV(self):
method test_orderCC2F (line 576) | def test_orderCC2F(self):
method test_orderE2CC (line 586) | def test_orderE2CC(self):
method test_orderE2CCV (line 594) | def test_orderE2CCV(self):
method test_orderCC2E (line 603) | def test_orderCC2E(self):
method test_orderCC2FV (line 613) | def test_orderCC2FV(self):
class TestAverating3DSimple (line 625) | class TestAverating3DSimple(unittest.TestCase):
method setUp (line 626) | def setUp(self):
method test_constantEdges (line 632) | def test_constantEdges(self):
method test_constantFaces (line 637) | def test_constantFaces(self):
class TestAveraging3D (line 643) | class TestAveraging3D(discretize.tests.OrderTest):
method getError (line 649) | def getError(self):
method test_orderN2CC (line 654) | def test_orderN2CC(self):
method test_orderN2F (line 662) | def test_orderN2F(self):
method test_orderN2E (line 672) | def test_orderN2E(self):
method test_orderF2CC (line 682) | def test_orderF2CC(self):
method test_orderF2CCV (line 692) | def test_orderF2CCV(self):
method test_orderE2CC (line 706) | def test_orderE2CC(self):
method test_orderE2CCV (line 716) | def test_orderE2CCV(self):
method test_orderCC2F (line 731) | def test_orderCC2F(self):
method test_orderCC2E (line 743) | def test_orderCC2E(self):
method test_orderCCV2F (line 753) | def test_orderCCV2F(self):
class MimeticProperties (line 770) | class MimeticProperties(unittest.TestCase):
method test_DivCurl (line 776) | def test_DivCurl(self):
method test_CurlGrad (line 790) | def test_CurlGrad(self):
FILE: tests/base/test_properties.py
function compare_meshes (line 7) | def compare_meshes(test, mesh0, mesh1):
class TensorTest (line 54) | class TensorTest(unittest.TestCase):
method setUp (line 58) | def setUp(self):
method test_save_load (line 61) | def test_save_load(self):
method test_copy (line 69) | def test_copy(self):
method test_base_updates (line 75) | def test_base_updates(self):
class CylTest (line 88) | class CylTest(unittest.TestCase):
method setUp (line 91) | def setUp(self):
method test_save_load (line 94) | def test_save_load(self):
method test_copy (line 102) | def test_copy(self):
class CurviTest (line 151) | class CurviTest(unittest.TestCase):
method setUp (line 152) | def setUp(self):
method test_save_load (line 163) | def test_save_load(self):
method test_copy (line 171) | def test_copy(self):
method test_base_updates (line 177) | def test_base_updates(self):
FILE: tests/base/test_slicer.py
function mesh (line 13) | def mesh():
function test_slicer_errors (line 17) | def test_slicer_errors(mesh):
function test_slicer_default_clim (line 26) | def test_slicer_default_clim(mesh):
function test_slicer_set_clim (line 34) | def test_slicer_set_clim(mesh):
function test_slicer_set_norm (line 41) | def test_slicer_set_norm(mesh):
function test_slicer_ones_clim (line 49) | def test_slicer_ones_clim(mesh):
function test_slicer_zeros_clim (line 56) | def test_slicer_zeros_clim(mesh):
FILE: tests/base/test_tensor.py
class BasicTensorMeshTests (line 13) | class BasicTensorMeshTests(unittest.TestCase):
method setUp (line 14) | def setUp(self):
method test_gridded_2D (line 21) | def test_gridded_2D(self):
method test_gridded_3D (line 27) | def test_gridded_3D(self):
method test_vectorN_2D (line 40) | def test_vectorN_2D(self):
method test_vectorCC_2D (line 47) | def test_vectorCC_2D(self):
method test_area_3D (line 55) | def test_area_3D(self):
method test_vol_3D (line 115) | def test_vol_3D(self):
method test_vol_2D (line 120) | def test_vol_2D(self):
method test_edge_3D (line 125) | def test_edge_3D(self):
method test_edge_2D (line 208) | def test_edge_2D(self):
method test_oneCell (line 213) | def test_oneCell(self):
method test_printing (line 218) | def test_printing(self):
method test_centering (line 223) | def test_centering(self):
method test_negative (line 231) | def test_negative(self):
method test_cent_neg (line 240) | def test_cent_neg(self):
method test_tensor (line 244) | def test_tensor(self):
method test_serialization (line 248) | def test_serialization(self):
class TestTensorMeshProperties (line 257) | class TestTensorMeshProperties:
method mesh (line 263) | def mesh(self, request):
method test_cell_nodes (line 276) | def test_cell_nodes(self, mesh):
method test_cell_bounds (line 281) | def test_cell_bounds(self, mesh):
class TestPoissonEqn (line 287) | class TestPoissonEqn(discretize.tests.OrderTest):
method getError (line 291) | def getError(self):
method test_orderForward (line 314) | def test_orderForward(self):
method test_orderBackward (line 319) | def test_orderBackward(self):
function random_tensor_mesh (line 326) | def random_tensor_mesh(request):
function test_tensor_point2index_inside_points (line 336) | def test_tensor_point2index_inside_points(random_tensor_mesh):
function test_tensor_point2index_outside_points (line 356) | def test_tensor_point2index_outside_points(random_tensor_mesh):
FILE: tests/base/test_tensor_cell.py
function test_slice_to_index (line 26) | def test_slice_to_index(slice_indices, expected_result):
class TestTensorCell (line 34) | class TestTensorCell:
method cell (line 38) | def cell(self, request):
method test_center (line 58) | def test_center(self, cell):
method test_index (line 68) | def test_index(self, cell):
method test_index_unraveled (line 78) | def test_index_unraveled(self, cell):
method test_bounds (line 88) | def test_bounds(self, cell):
method test_eq (line 102) | def test_eq(self, cell, change_h, change_origin, change_index, change_...
method test_eq_invalid_type (line 119) | def test_eq_invalid_type(self, cell):
class TestTensorMeshCells (line 132) | class TestTensorMeshCells:
method mesh (line 136) | def mesh(self, request):
method test_cell_centers (line 150) | def test_cell_centers(self, mesh):
method test_cell_bounds (line 158) | def test_cell_bounds(self, mesh):
method test_cell_int_indices (line 181) | def test_cell_int_indices(self, mesh):
method test_cell_negative_int_indices (line 212) | def test_cell_negative_int_indices(self, mesh):
method test_cells_single_slice (line 234) | def test_cells_single_slice(self, mesh, start, stop, step):
method test_cells_slices (line 244) | def test_cells_slices(self, mesh, step):
method test_cells_slices_negative_bounds (line 268) | def test_cells_slices_negative_bounds(self, mesh, step):
method generate_expected_cells (line 298) | def generate_expected_cells(self, mesh, start, stop, step):
class TestNeighbors (line 333) | class TestNeighbors:
method sample_1D (line 337) | def sample_1D(self):
method sample_2D (line 345) | def sample_2D(self):
method sample_3D (line 353) | def sample_3D(self):
method test_neighbors_1D (line 361) | def test_neighbors_1D(self, sample_1D, index):
method test_neighbors_2D (line 378) | def test_neighbors_2D(self, sample_2D, index_x, index_y):
method test_neighbors_3D (line 410) | def test_neighbors_3D(self, sample_3D, index_x, index_y, index_z):
class TestNodes (line 446) | class TestNodes:
method cell_1D (line 450) | def cell_1D(self):
method cell_2D (line 455) | def cell_2D(self):
method cell_3D (line 463) | def cell_3D(self):
method test_nodes_indices_1D (line 473) | def test_nodes_indices_1D(self, cell_1D):
method test_nodes_indices_2D (line 477) | def test_nodes_indices_2D(self, cell_2D):
method test_nodes_indices_3D (line 481) | def test_nodes_indices_3D(self, cell_3D):
class TestEdges (line 486) | class TestEdges:
method mesh_1D (line 490) | def mesh_1D(self):
method mesh_2D (line 497) | def mesh_2D(self):
method mesh_3D (line 504) | def mesh_3D(self):
method test_edges_1D (line 510) | def test_edges_1D(self, mesh_1D):
method test_edges_2D (line 519) | def test_edges_2D(self, mesh_2D):
method test_edges_3D (line 533) | def test_edges_3D(self, mesh_3D):
class TestFaces (line 556) | class TestFaces:
method mesh_1D (line 560) | def mesh_1D(self):
method mesh_2D (line 567) | def mesh_2D(self):
method mesh_3D (line 574) | def mesh_3D(self):
method test_faces_1D (line 580) | def test_faces_1D(self, mesh_1D):
method test_faces_2D (line 589) | def test_faces_2D(self, mesh_2D):
method test_faces_3D (line 603) | def test_faces_3D(self, mesh_3D):
FILE: tests/base/test_tensor_innerproduct.py
class TestInnerProducts (line 8) | class TestInnerProducts(discretize.tests.OrderTest):
method getError (line 16) | def getError(self):
method test_order1_edges (line 82) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 89) | def test_order1_edges_invert_model(self):
method test_order3_edges (line 96) | def test_order3_edges(self):
method test_order3_edges_invert_model (line 103) | def test_order3_edges_invert_model(self):
method test_order6_edges (line 110) | def test_order6_edges(self):
method test_order6_edges_invert_model (line 117) | def test_order6_edges_invert_model(self):
method test_order1_faces (line 124) | def test_order1_faces(self):
method test_order1_faces_invert_model (line 131) | def test_order1_faces_invert_model(self):
method test_order3_faces (line 138) | def test_order3_faces(self):
method test_order3_faces_invert_model (line 145) | def test_order3_faces_invert_model(self):
method test_order6_faces (line 152) | def test_order6_faces(self):
method test_order6_faces_invert_model (line 159) | def test_order6_faces_invert_model(self):
class TestInnerProductsFaceProperties3D (line 167) | class TestInnerProductsFaceProperties3D(discretize.tests.OrderTest):
method getError (line 175) | def getError(self):
method test_order1_edges (line 256) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 263) | def test_order1_edges_invert_model(self):
method test_order1_edges_invert_matrix (line 270) | def test_order1_edges_invert_matrix(self):
method test_order1_edges_invert_matrix_and_model (line 277) | def test_order1_edges_invert_matrix_and_model(self):
method test_order1_faces (line 284) | def test_order1_faces(self):
method test_order1_faces_invert_model (line 291) | def test_order1_faces_invert_model(self):
method test_order1_faces_invert_matrix (line 298) | def test_order1_faces_invert_matrix(self):
method test_order1_faces_invert_matrix_and_model (line 305) | def test_order1_faces_invert_matrix_and_model(self):
class TestInnerProductsEdgeProperties3D (line 313) | class TestInnerProductsEdgeProperties3D(discretize.tests.OrderTest):
method getError (line 321) | def getError(self):
method test_order1_edges (line 372) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 379) | def test_order1_edges_invert_model(self):
method test_order1_edges_invert_matrix (line 386) | def test_order1_edges_invert_matrix(self):
method test_order1_edges_invert_matrix_and_model (line 393) | def test_order1_edges_invert_matrix_and_model(self):
class TestInnerProducts2D (line 401) | class TestInnerProducts2D(discretize.tests.OrderTest):
method getError (line 409) | def getError(self):
method test_order1_edges (line 461) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 468) | def test_order1_edges_invert_model(self):
method test_order3_edges (line 475) | def test_order3_edges(self):
method test_order3_edges_invert_model (line 482) | def test_order3_edges_invert_model(self):
method test_order6_edges (line 489) | def test_order6_edges(self):
method test_order6_edges_invert_model (line 496) | def test_order6_edges_invert_model(self):
method test_order1_faces (line 503) | def test_order1_faces(self):
method test_order1_faces_invert_model (line 510) | def test_order1_faces_invert_model(self):
method test_order2_faces (line 517) | def test_order2_faces(self):
method test_order2_faces_invert_model (line 524) | def test_order2_faces_invert_model(self):
method test_order3_faces (line 531) | def test_order3_faces(self):
method test_order3_faces_invert_model (line 538) | def test_order3_faces_invert_model(self):
class TestInnerProductsFaceProperties2D (line 546) | class TestInnerProductsFaceProperties2D(discretize.tests.OrderTest):
method getError (line 554) | def getError(self):
method test_order1_edges (line 611) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 617) | def test_order1_edges_invert_model(self):
method test_order1_faces (line 623) | def test_order1_faces(self):
method test_order1_faces_invert_model (line 629) | def test_order1_faces_invert_model(self):
class TestInnerProductsEdgeProperties2D (line 636) | class TestInnerProductsEdgeProperties2D(discretize.tests.OrderTest):
method getError (line 644) | def getError(self):
method test_order1_edges (line 685) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 691) | def test_order1_edges_invert_model(self):
class TestInnerProducts1D (line 698) | class TestInnerProducts1D(discretize.tests.OrderTest):
method getError (line 706) | def getError(self):
method test_order1_faces (line 731) | def test_order1_faces(self):
method test_order1_faces_invert_model (line 738) | def test_order1_faces_invert_model(self):
class TestTensorSizeErrorRaises (line 746) | class TestTensorSizeErrorRaises(unittest.TestCase):
method setUp (line 749) | def setUp(self):
method test_edge_inner_product_surface (line 753) | def test_edge_inner_product_surface(self):
method test_face_inner_product_surface (line 758) | def test_face_inner_product_surface(self):
method test_edge_inner_product_line (line 763) | def test_edge_inner_product_line(self):
FILE: tests/base/test_tensor_innerproduct_derivs.py
class TestInnerProductsDerivsTensor (line 9) | class TestInnerProductsDerivsTensor(unittest.TestCase):
method doTestFace (line 10) | def doTestFace(
method doTestEdge (line 49) | def doTestEdge(
method test_FaceIP_1D_float (line 88) | def test_FaceIP_1D_float(self):
method test_FaceIP_2D_float (line 91) | def test_FaceIP_2D_float(self):
method test_FaceIP_3D_float (line 94) | def test_FaceIP_3D_float(self):
method test_FaceIP_1D_isotropic (line 97) | def test_FaceIP_1D_isotropic(self):
method test_FaceIP_2D_isotropic (line 100) | def test_FaceIP_2D_isotropic(self):
method test_FaceIP_3D_isotropic (line 103) | def test_FaceIP_3D_isotropic(self):
method test_FaceIP_2D_anisotropic (line 106) | def test_FaceIP_2D_anisotropic(self):
method test_FaceIP_3D_anisotropic (line 109) | def test_FaceIP_3D_anisotropic(self):
method test_FaceIP_2D_tensor (line 112) | def test_FaceIP_2D_tensor(self):
method test_FaceIP_3D_tensor (line 115) | def test_FaceIP_3D_tensor(self):
method test_FaceIP_1D_float_fast (line 118) | def test_FaceIP_1D_float_fast(self):
method test_FaceIP_2D_float_fast (line 121) | def test_FaceIP_2D_float_fast(self):
method test_FaceIP_3D_float_fast (line 124) | def test_FaceIP_3D_float_fast(self):
method test_FaceIP_1D_isotropic_fast (line 127) | def test_FaceIP_1D_isotropic_fast(self):
method test_FaceIP_2D_isotropic_fast (line 130) | def test_FaceIP_2D_isotropic_fast(self):
method test_FaceIP_3D_isotropic_fast (line 133) | def test_FaceIP_3D_isotropic_fast(self):
method test_FaceIP_2D_anisotropic_fast (line 136) | def test_FaceIP_2D_anisotropic_fast(self):
method test_FaceIP_3D_anisotropic_fast (line 139) | def test_FaceIP_3D_anisotropic_fast(self):
method test_EdgeIP_1D_float (line 142) | def test_EdgeIP_1D_float(self):
method test_EdgeIP_2D_float (line 145) | def test_EdgeIP_2D_float(self):
method test_EdgeIP_3D_float (line 148) | def test_EdgeIP_3D_float(self):
method test_EdgeIP_1D_isotropic (line 151) | def test_EdgeIP_1D_isotropic(self):
method test_EdgeIP_2D_isotropic (line 154) | def test_EdgeIP_2D_isotropic(self):
method test_EdgeIP_3D_isotropic (line 157) | def test_EdgeIP_3D_isotropic(self):
method test_EdgeIP_2D_anisotropic (line 160) | def test_EdgeIP_2D_anisotropic(self):
method test_EdgeIP_3D_anisotropic (line 163) | def test_EdgeIP_3D_anisotropic(self):
method test_EdgeIP_2D_tensor (line 166) | def test_EdgeIP_2D_tensor(self):
method test_EdgeIP_3D_tensor (line 169) | def test_EdgeIP_3D_tensor(self):
method test_EdgeIP_1D_float_fast (line 172) | def test_EdgeIP_1D_float_fast(self):
method test_EdgeIP_2D_float_fast (line 175) | def test_EdgeIP_2D_float_fast(self):
method test_EdgeIP_3D_float_fast (line 178) | def test_EdgeIP_3D_float_fast(self):
method test_EdgeIP_1D_isotropic_fast (line 181) | def test_EdgeIP_1D_isotropic_fast(self):
method test_EdgeIP_2D_isotropic_fast (line 184) | def test_EdgeIP_2D_isotropic_fast(self):
method test_EdgeIP_3D_isotropic_fast (line 187) | def test_EdgeIP_3D_isotropic_fast(self):
method test_EdgeIP_2D_anisotropic_fast (line 190) | def test_EdgeIP_2D_anisotropic_fast(self):
method test_EdgeIP_3D_anisotropic_fast (line 193) | def test_EdgeIP_3D_anisotropic_fast(self):
method test_FaceIP_1D_float_fast_harmonic (line 196) | def test_FaceIP_1D_float_fast_harmonic(self):
method test_FaceIP_2D_float_fast_harmonic (line 203) | def test_FaceIP_2D_float_fast_harmonic(self):
method test_FaceIP_3D_float_fast_harmonic (line 210) | def test_FaceIP_3D_float_fast_harmonic(self):
method test_FaceIP_1D_isotropic_fast_harmonic (line 217) | def test_FaceIP_1D_isotropic_fast_harmonic(self):
method test_FaceIP_2D_isotropic_fast_harmonic (line 224) | def test_FaceIP_2D_isotropic_fast_harmonic(self):
method test_FaceIP_3D_isotropic_fast_harmonic (line 231) | def test_FaceIP_3D_isotropic_fast_harmonic(self):
method test_FaceIP_2D_anisotropic_fast_harmonic (line 238) | def test_FaceIP_2D_anisotropic_fast_harmonic(self):
method test_FaceIP_3D_anisotropic_fast_harmonic (line 245) | def test_FaceIP_3D_anisotropic_fast_harmonic(self):
method test_FaceIP_2D_float_Curv (line 252) | def test_FaceIP_2D_float_Curv(self):
method test_FaceIP_3D_float_Curv (line 255) | def test_FaceIP_3D_float_Curv(self):
method test_FaceIP_2D_isotropic_Curv (line 258) | def test_FaceIP_2D_isotropic_Curv(self):
method test_FaceIP_3D_isotropic_Curv (line 261) | def test_FaceIP_3D_isotropic_Curv(self):
method test_FaceIP_2D_anisotropic_Curv (line 264) | def test_FaceIP_2D_anisotropic_Curv(self):
method test_FaceIP_3D_anisotropic_Curv (line 267) | def test_FaceIP_3D_anisotropic_Curv(self):
method test_FaceIP_2D_tensor_Curv (line 270) | def test_FaceIP_2D_tensor_Curv(self):
method test_FaceIP_3D_tensor_Curv (line 273) | def test_FaceIP_3D_tensor_Curv(self):
method test_FaceIP_2D_float_fast_Curv (line 276) | def test_FaceIP_2D_float_fast_Curv(self):
method test_FaceIP_3D_float_fast_Curv (line 279) | def test_FaceIP_3D_float_fast_Curv(self):
method test_FaceIP_2D_isotropic_fast_Curv (line 282) | def test_FaceIP_2D_isotropic_fast_Curv(self):
method test_FaceIP_3D_isotropic_fast_Curv (line 285) | def test_FaceIP_3D_isotropic_fast_Curv(self):
method test_FaceIP_2D_anisotropic_fast_Curv (line 288) | def test_FaceIP_2D_anisotropic_fast_Curv(self):
method test_FaceIP_3D_anisotropic_fast_Curv (line 291) | def test_FaceIP_3D_anisotropic_fast_Curv(self):
method test_EdgeIP_2D_float_Curv (line 294) | def test_EdgeIP_2D_float_Curv(self):
method test_EdgeIP_3D_float_Curv (line 297) | def test_EdgeIP_3D_float_Curv(self):
method test_EdgeIP_2D_isotropic_Curv (line 300) | def test_EdgeIP_2D_isotropic_Curv(self):
method test_EdgeIP_3D_isotropic_Curv (line 303) | def test_EdgeIP_3D_isotropic_Curv(self):
method test_EdgeIP_2D_anisotropic_Curv (line 306) | def test_EdgeIP_2D_anisotropic_Curv(self):
method test_EdgeIP_3D_anisotropic_Curv (line 309) | def test_EdgeIP_3D_anisotropic_Curv(self):
method test_EdgeIP_2D_tensor_Curv (line 312) | def test_EdgeIP_2D_tensor_Curv(self):
method test_EdgeIP_3D_tensor_Curv (line 315) | def test_EdgeIP_3D_tensor_Curv(self):
method test_EdgeIP_2D_float_fast_Curv (line 318) | def test_EdgeIP_2D_float_fast_Curv(self):
method test_EdgeIP_3D_float_fast_Curv (line 321) | def test_EdgeIP_3D_float_fast_Curv(self):
method test_EdgeIP_2D_isotropic_fast_Curv (line 324) | def test_EdgeIP_2D_isotropic_fast_Curv(self):
method test_EdgeIP_3D_isotropic_fast_Curv (line 327) | def test_EdgeIP_3D_isotropic_fast_Curv(self):
method test_EdgeIP_2D_anisotropic_fast_Curv (line 330) | def test_EdgeIP_2D_anisotropic_fast_Curv(self):
method test_EdgeIP_3D_anisotropic_fast_Curv (line 333) | def test_EdgeIP_3D_anisotropic_fast_Curv(self):
class TestFacePropertiesInnerProductsDerivsTensor (line 337) | class TestFacePropertiesInnerProductsDerivsTensor(unittest.TestCase):
method doTestFace (line 338) | def doTestFace(self, h, rep, meshType, invert_model=False, invert_matr...
method doTestEdge (line 371) | def doTestEdge(self, h, rep, meshType, invert_model=False, invert_matr...
method test_FaceIP_2D_float (line 404) | def test_FaceIP_2D_float(self):
method test_FaceIP_3D_float (line 407) | def test_FaceIP_3D_float(self):
method test_FaceIP_2D_isotropic (line 410) | def test_FaceIP_2D_isotropic(self):
method test_FaceIP_3D_isotropic (line 413) | def test_FaceIP_3D_isotropic(self):
method test_EdgeIP_2D_float (line 416) | def test_EdgeIP_2D_float(self):
method test_EdgeIP_3D_float (line 419) | def test_EdgeIP_3D_float(self):
method test_EdgeIP_2D_isotropic (line 422) | def test_EdgeIP_2D_isotropic(self):
method test_EdgeIP_3D_isotropic (line 425) | def test_EdgeIP_3D_isotropic(self):
method test_FaceIP_2D_float_invert_all (line 428) | def test_FaceIP_2D_float_invert_all(self):
method test_FaceIP_3D_float_invert_all (line 433) | def test_FaceIP_3D_float_invert_all(self):
method test_FaceIP_2D_isotropic_invert_all (line 440) | def test_FaceIP_2D_isotropic_invert_all(self):
method test_FaceIP_3D_isotropic_invert_all (line 445) | def test_FaceIP_3D_isotropic_invert_all(self):
method test_EdgeIP_2D_float_invert_all (line 452) | def test_EdgeIP_2D_float_invert_all(self):
method test_EdgeIP_3D_float_invert_all (line 457) | def test_EdgeIP_3D_float_invert_all(self):
method test_EdgeIP_2D_isotropic_invert_all (line 464) | def test_EdgeIP_2D_isotropic_invert_all(self):
method test_EdgeIP_3D_isotropic_invert_all (line 469) | def test_EdgeIP_3D_isotropic_invert_all(self):
class TestEdgePropertiesInnerProductsDerivsTensor (line 477) | class TestEdgePropertiesInnerProductsDerivsTensor(unittest.TestCase):
method doTestEdge (line 478) | def doTestEdge(self, h, rep, meshType, invert_model=False, invert_matr...
method test_EdgeIP_2D_float (line 515) | def test_EdgeIP_2D_float(self):
method test_EdgeIP_3D_float (line 518) | def test_EdgeIP_3D_float(self):
method test_EdgeIP_2D_isotropic (line 521) | def test_EdgeIP_2D_isotropic(self):
method test_EdgeIP_3D_isotropic (line 524) | def test_EdgeIP_3D_isotropic(self):
method test_EdgeIP_2D_float_invert_all (line 527) | def test_EdgeIP_2D_float_invert_all(self):
method test_EdgeIP_3D_float_invert_all (line 532) | def test_EdgeIP_3D_float_invert_all(self):
method test_EdgeIP_2D_isotropic_invert_all (line 539) | def test_EdgeIP_2D_isotropic_invert_all(self):
method test_EdgeIP_3D_isotropic_invert_all (line 544) | def test_EdgeIP_3D_isotropic_invert_all(self):
class TestTensorSizeErrorRaises (line 552) | class TestTensorSizeErrorRaises(unittest.TestCase):
method setUp (line 555) | def setUp(self):
method test_edge_inner_product_surface_deriv (line 559) | def test_edge_inner_product_surface_deriv(self):
method test_face_inner_product_surface_deriv (line 564) | def test_face_inner_product_surface_deriv(self):
method test_edge_inner_product_line_deriv (line 569) | def test_edge_inner_product_line_deriv(self):
class TestNone (line 575) | class TestNone(unittest.TestCase):
method setUp (line 578) | def setUp(self):
method test_edge_inner_product_surface_deriv (line 581) | def test_edge_inner_product_surface_deriv(self):
method test_face_inner_product_surface_deriv (line 584) | def test_face_inner_product_surface_deriv(self):
method test_edge_inner_product_line_deriv (line 587) | def test_edge_inner_product_line_deriv(self):
FILE: tests/base/test_tensor_io.py
function test_write_read_ubc_mesh_model (line 14) | def test_write_read_ubc_mesh_model(dim, tmp_path):
function test_VTKfiles (line 43) | def test_VTKfiles(tmp_path):
FILE: tests/base/test_tensor_omf.py
class TestTensorMeshOMF (line 16) | class TestTensorMeshOMF(unittest.TestCase):
method setUp (line 17) | def setUp(self):
method test_to_omf (line 22) | def test_to_omf(self):
method test_from_omf (line 52) | def test_from_omf(self):
FILE: tests/base/test_tensor_vtk.py
class TestTensorMeshVTK (line 15) | class TestTensorMeshVTK(unittest.TestCase):
method setUp (line 16) | def setUp(self):
method test_VTK_object_conversion (line 21) | def test_VTK_object_conversion(self):
FILE: tests/base/test_tests.py
class TestAssertIsAdjoint (line 16) | class TestAssertIsAdjoint:
method test_defaults (line 17) | def test_defaults(self, capsys):
method test_different_shape (line 51) | def test_different_shape(self):
method test_complex_clinear (line 72) | def test_complex_clinear(self):
class TestCheckDerivative (line 86) | class TestCheckDerivative:
method test_simplePass (line 87) | def test_simplePass(self):
method test_simpleFunction (line 96) | def test_simpleFunction(self):
method test_simpleFail (line 105) | def test_simpleFail(self):
function test_expected_order_pass (line 117) | def test_expected_order_pass(test_type):
function test_expected_order_failed (line 137) | def test_expected_order_failed(test_type):
function test_expected_order_bad_test_type (line 157) | def test_expected_order_bad_test_type():
function test_import_time (line 164) | def test_import_time():
function test_random_test_warning (line 177) | def test_random_test_warning():
FILE: tests/base/test_utils.py
class TestSequenceFunctions (line 32) | class TestSequenceFunctions(unittest.TestCase):
method setUp (line 33) | def setUp(self):
method test_mkvc1 (line 38) | def test_mkvc1(self):
method test_mkvc2 (line 42) | def test_mkvc2(self):
method test_mkvc3 (line 46) | def test_mkvc3(self):
method test_ndgrid_2D (line 50) | def test_ndgrid_2D(self):
method test_ndgrid_3D (line 59) | def test_ndgrid_3D(self):
method test_sub2ind (line 76) | def test_sub2ind(self):
method test_ind2sub (line 87) | def test_ind2sub(self):
method test_index_cube_2D (line 92) | def test_index_cube_2D(self):
method test_index_cube_3D (line 99) | def test_index_cube_3D(self):
method test_invXXXBlockDiagonal (line 126) | def test_invXXXBlockDiagonal(self):
method test_inverse_property_tensor2D (line 157) | def test_inverse_property_tensor2D(self):
method test_TensorType2D (line 178) | def test_TensorType2D(self):
method test_TensorType3D (line 194) | def test_TensorType3D(self):
method test_inverse_property_tensor3D (line 213) | def test_inverse_property_tensor3D(self):
method test_is_scalar (line 237) | def test_is_scalar(self):
method test_as_array_n_by_dim (line 251) | def test_as_array_n_by_dim(self):
class TestZero (line 273) | class TestZero(unittest.TestCase):
method test_zero (line 274) | def test_zero(self):
method test_mat_zero (line 305) | def test_mat_zero(self):
method test_numpy_multiply (line 310) | def test_numpy_multiply(self):
method test_one (line 321) | def test_one(self):
method test_mat_one (line 363) | def test_mat_one(self):
method test_mat_shape (line 385) | def test_mat_shape(self):
method test_numpy_one (line 396) | def test_numpy_one(self):
method test_both (line 413) | def test_both(self):
class TestMeshUtils (line 424) | class TestMeshUtils(unittest.TestCase):
method test_extract_core_mesh (line 425) | def test_extract_core_mesh(self):
method test_active_from_xyz (line 462) | def test_active_from_xyz(self):
function test_cross2d (line 622) | def test_cross2d():
FILE: tests/base/test_view.py
class Cyl3DView (line 18) | class Cyl3DView(unittest.TestCase):
method setUp (line 19) | def setUp(self):
method test_incorrectAxesWarnings (line 22) | def test_incorrectAxesWarnings(self):
method test_plot_image (line 56) | def test_plot_image(self):
FILE: tests/base/test_volume_avg.py
function generate_mesh (line 8) | def generate_mesh(dim, mesh_type, tree_point=None, sub_mesh=False, seed=0):
function test_volume_average (line 42) | def test_volume_average(dim, mesh1_type, mesh2_type, same_base, sub_mesh...
function test_errors (line 98) | def test_errors():
FILE: tests/boundaries/test_boundary_integrals.py
function u (line 7) | def u(*args):
function u_cyl (line 18) | def u_cyl(*args):
function v (line 23) | def v(*args):
function v_cyl (line 34) | def v_cyl(*args):
function w (line 40) | def w(*args):
function w_cyl (line 48) | def w_cyl(*args):
class Test1DBoundaryIntegral (line 83) | class Test1DBoundaryIntegral(discretize.tests.OrderTest):
method getError (line 90) | def getError(self):
method test_orderWeakCellGradIntegral (line 116) | def test_orderWeakCellGradIntegral(self):
method test_orderWeakEdgeDivIntegral (line 121) | def test_orderWeakEdgeDivIntegral(self):
class Test2DBoundaryIntegral (line 127) | class Test2DBoundaryIntegral(discretize.tests.OrderTest):
method getError (line 140) | def getError(self):
method test_orderWeakCellGradIntegral (line 190) | def test_orderWeakCellGradIntegral(self):
method test_orderWeakEdgeDivIntegral (line 195) | def test_orderWeakEdgeDivIntegral(self):
method test_orderWeakFaceCurlIntegral (line 200) | def test_orderWeakFaceCurlIntegral(self):
class Test3DBoundaryIntegral (line 206) | class Test3DBoundaryIntegral(discretize.tests.OrderTest):
method getError (line 220) | def getError(self):
method test_orderWeakCellGradIntegral (line 268) | def test_orderWeakCellGradIntegral(self):
method test_orderWeakEdgeDivIntegral (line 273) | def test_orderWeakEdgeDivIntegral(self):
method test_orderWeakFaceCurlIntegral (line 278) | def test_orderWeakFaceCurlIntegral(self):
FILE: tests/boundaries/test_boundary_maxwell.py
class TestFz2D_InhomogeneousDirichlet (line 7) | class TestFz2D_InhomogeneousDirichlet(discretize.tests.OrderTest):
method getError (line 14) | def getError(self):
method test_orderX (line 44) | def test_orderX(self):
class TestE3D_Inhomogeneous (line 50) | class TestE3D_Inhomogeneous(discretize.tests.OrderTest):
method getError (line 57) | def getError(self):
method test_orderFace (line 117) | def test_orderFace(self):
method test_orderNuemann (line 122) | def test_orderNuemann(self):
FILE: tests/boundaries/test_boundary_poisson.py
class TestCC1D_InhomogeneousDirichlet (line 10) | class TestCC1D_InhomogeneousDirichlet(discretize.tests.OrderTest):
method getError (line 17) | def getError(self):
method test_orderX (line 47) | def test_orderX(self):
class TestCC2D_InhomogeneousDirichlet (line 53) | class TestCC2D_InhomogeneousDirichlet(discretize.tests.OrderTest):
method getError (line 60) | def getError(self):
method test_orderX (line 90) | def test_orderX(self):
class TestCC1D_InhomogeneousNeumann (line 96) | class TestCC1D_InhomogeneousNeumann(discretize.tests.OrderTest):
method getError (line 103) | def getError(self):
method test_orderJ (line 151) | def test_orderJ(self):
method test_orderXJ (line 156) | def test_orderXJ(self):
class TestCC2D_InhomogeneousNeumann (line 162) | class TestCC2D_InhomogeneousNeumann(discretize.tests.OrderTest):
method getError (line 170) | def getError(self):
method test_orderX (line 219) | def test_orderX(self):
class TestCC1D_InhomogeneousMixed (line 225) | class TestCC1D_InhomogeneousMixed(discretize.tests.OrderTest):
method getError (line 232) | def getError(self):
method test_orderX (line 272) | def test_orderX(self):
method test_orderXJ (line 277) | def test_orderXJ(self):
class TestCC2D_InhomogeneousMixed (line 283) | class TestCC2D_InhomogeneousMixed(discretize.tests.OrderTest):
method getError (line 291) | def getError(self):
method test_orderX (line 344) | def test_orderX(self):
class TestCC3D_InhomogeneousMixed (line 350) | class TestCC3D_InhomogeneousMixed(discretize.tests.OrderTest):
method getError (line 357) | def getError(self):
method test_orderX (line 432) | def test_orderX(self):
class TestN1D_boundaries (line 438) | class TestN1D_boundaries(discretize.tests.OrderTest):
method getError (line 446) | def getError(self):
method test_orderNuemannX (line 500) | def test_orderNuemannX(self):
method test_orderRobinX (line 505) | def test_orderRobinX(self):
method test_orderMixed (line 510) | def test_orderMixed(self):
class TestN2D_boundaries (line 516) | class TestN2D_boundaries(discretize.tests.OrderTest):
method getError (line 525) | def getError(self):
method test_orderNuemannX (line 601) | def test_orderNuemannX(self):
method test_orderRobinX (line 606) | def test_orderRobinX(self):
method test_orderMixed (line 611) | def test_orderMixed(self):
class TestN3D_boundaries (line 617) | class TestN3D_boundaries(discretize.tests.OrderTest):
method getError (line 626) | def getError(self):
method test_orderNuemannX (line 725) | def test_orderNuemannX(self):
method test_orderRobinX (line 730) | def test_orderRobinX(self):
method test_orderMixed (line 735) | def test_orderMixed(self):
FILE: tests/boundaries/test_errors.py
class RobinOperatorTest (line 9) | class RobinOperatorTest(unittest.TestCase):
method setUp (line 10) | def setUp(self):
method testCellGradBroadcasting (line 13) | def testCellGradBroadcasting(self):
method testEdgeDivBroadcasting (line 46) | def testEdgeDivBroadcasting(self):
method testEdgeDivErrors (line 108) | def testEdgeDivErrors(self):
class mesh1DTests (line 133) | class mesh1DTests(unittest.TestCase):
method setUp (line 134) | def setUp(self):
method testItems (line 137) | def testItems(self):
FILE: tests/boundaries/test_tensor_boundary.py
function getxBCyBC_CC (line 9) | def getxBCyBC_CC(mesh, alpha, beta, gamma):
class Test1D_InhomogeneousMixed (line 177) | class Test1D_InhomogeneousMixed(discretize.tests.OrderTest):
method getError (line 184) | def getError(self):
method test_order (line 234) | def test_order(self):
class Test2D_InhomogeneousMixed (line 241) | class Test2D_InhomogeneousMixed(discretize.tests.OrderTest):
method getError (line 248) | def getError(self):
method test_order (line 328) | def test_order(self):
class Test3D_InhomogeneousMixed (line 335) | class Test3D_InhomogeneousMixed(discretize.tests.OrderTest):
method getError (line 342) | def getError(self):
method test_order (line 459) | def test_order(self):
FILE: tests/boundaries/test_tensor_boundary_poisson.py
class Test1D_InhomogeneousDirichlet (line 12) | class Test1D_InhomogeneousDirichlet(discretize.tests.OrderTest):
method getError (line 19) | def getError(self):
method test_orderJ (line 70) | def test_orderJ(self):
method test_orderQ (line 75) | def test_orderQ(self):
method test_orderX (line 80) | def test_orderX(self):
method test_orderXJ (line 85) | def test_orderXJ(self):
class Test2D_InhomogeneousDirichlet (line 91) | class Test2D_InhomogeneousDirichlet(discretize.tests.OrderTest):
method getError (line 98) | def getError(self):
method test_orderJ (line 152) | def test_orderJ(self):
method test_orderQ (line 157) | def test_orderQ(self):
method test_orderX (line 162) | def test_orderX(self):
method test_orderXJ (line 167) | def test_orderXJ(self):
class Test1D_InhomogeneousNeumann (line 173) | class Test1D_InhomogeneousNeumann(discretize.tests.OrderTest):
method getError (line 180) | def getError(self):
method test_orderJ (line 234) | def test_orderJ(self):
method test_orderQ (line 239) | def test_orderQ(self):
method test_orderXJ (line 244) | def test_orderXJ(self):
class Test2D_InhomogeneousNeumann (line 250) | class Test2D_InhomogeneousNeumann(discretize.tests.OrderTest):
method getError (line 258) | def getError(self):
method test_orderJ (line 319) | def test_orderJ(self):
method test_orderQ (line 324) | def test_orderQ(self):
method test_orderXJ (line 329) | def test_orderXJ(self):
class Test1D_InhomogeneousMixed (line 335) | class Test1D_InhomogeneousMixed(discretize.tests.OrderTest):
method getError (line 342) | def getError(self):
method test_orderJ (line 396) | def test_orderJ(self):
method test_orderQ (line 401) | def test_orderQ(self):
method test_orderXJ (line 406) | def test_orderXJ(self):
class Test2D_InhomogeneousMixed (line 412) | class Test2D_InhomogeneousMixed(discretize.tests.OrderTest):
method getError (line 420) | def getError(self):
method test_orderJ (line 496) | def test_orderJ(self):
method test_orderQ (line 501) | def test_orderQ(self):
method test_orderXJ (line 506) | def test_orderXJ(self):
FILE: tests/cyl/test_cyl.py
class TestCylSymmetricMesh (line 11) | class TestCylSymmetricMesh(unittest.TestCase):
method setUp (line 12) | def setUp(self):
method test_vectorsCC (line 17) | def test_vectorsCC(self):
method test_vectorsN (line 25) | def test_vectorsN(self):
method test_edge (line 33) | def test_edge(self):
method test_area (line 37) | def test_area(self):
method test_vol (line 46) | def test_vol(self):
method test_vol_simple (line 52) | def test_vol_simple(self):
method test_gridSizes (line 59) | def test_gridSizes(self):
method test_gridCC (line 71) | def test_gridCC(self):
method test_gridN (line 78) | def test_gridN(self):
method test_gridFx (line 85) | def test_gridFx(self):
method test_gridFz (line 92) | def test_gridFz(self):
method test_gridEy (line 99) | def test_gridEy(self):
method test_lightOperators (line 106) | def test_lightOperators(self):
method test_getInterpMatCartMesh_Cells (line 109) | def test_getInterpMatCartMesh_Cells(self):
method test_getInterpMatCartMesh_Cells2Nodes (line 128) | def test_getInterpMatCartMesh_Cells2Nodes(self):
method test_getInterpMatCartMesh_Faces (line 149) | def test_getInterpMatCartMesh_Faces(self):
method test_getInterpMatCartMesh_Faces2Edges (line 180) | def test_getInterpMatCartMesh_Faces2Edges(self):
method test_getInterpMatCartMesh_Edges (line 213) | def test_getInterpMatCartMesh_Edges(self):
method test_getInterpMatCartMesh_Edges2Faces (line 244) | def test_getInterpMatCartMesh_Edges2Faces(self):
method test_serialization (line 275) | def test_serialization(self):
class TestFaceDiv2D (line 297) | class TestFaceDiv2D(tests.OrderTest):
method getError (line 302) | def getError(self):
method test_order (line 320) | def test_order(self):
class TestEdgeCurl2D (line 324) | class TestEdgeCurl2D(tests.OrderTest):
method getError (line 329) | def getError(self):
method test_order (line 359) | def test_order(self):
class TestCellGrad2D_Dirichlet (line 363) | class TestCellGrad2D_Dirichlet(unittest.TestCase):
method setUp (line 390) | def setUp(self):
method test_NotImplementedError (line 395) | def test_NotImplementedError(self):
class TestAveragingSimple (line 400) | class TestAveragingSimple(unittest.TestCase):
method setUp (line 401) | def setUp(self):
method test_simpleEdges (line 406) | def test_simpleEdges(self):
method test_constantFaces (line 417) | def test_constantFaces(self):
class TestAveE2CC (line 424) | class TestAveE2CC(tests.OrderTest):
method getError (line 430) | def getError(self):
method test_order (line 441) | def test_order(self):
class TestAveE2CCV (line 445) | class TestAveE2CCV(tests.OrderTest):
method getError (line 451) | def getError(self):
method test_order (line 462) | def test_order(self):
class TestAveF2CCV (line 466) | class TestAveF2CCV(tests.OrderTest):
method getError (line 471) | def getError(self):
method test_order (line 489) | def test_order(self):
class TestAveF2CC (line 493) | class TestAveF2CC(tests.OrderTest):
method getError (line 498) | def getError(self):
method test_order (line 511) | def test_order(self):
class TestCyl3DMesh (line 570) | class TestCyl3DMesh(unittest.TestCase):
method setUp (line 571) | def setUp(self):
method test_vectorsCC (line 577) | def test_vectorsCC(self):
method test_vectorsN (line 585) | def test_vectorsN(self):
function test_non_sym_errors (line 594) | def test_non_sym_errors():
function test_sym_errors (line 639) | def test_sym_errors():
FILE: tests/cyl/test_cyl3D.py
class TestCyl3DGeometries (line 10) | class TestCyl3DGeometries(unittest.TestCase):
method setUp (line 11) | def setUp(self):
method test_areas (line 19) | def test_areas(self):
method test_edges (line 39) | def test_edges(self):
method test_vol (line 68) | def test_vol(self):
function test_boundary_items (line 83) | def test_boundary_items():
class Cyl3DGrid (line 108) | class Cyl3DGrid(unittest.TestCase):
method setUp (line 109) | def setUp(self):
method test_counting (line 112) | def test_counting(self):
method test_gridCC (line 151) | def test_gridCC(self):
method test_gridN (line 184) | def test_gridN(self):
method test_gridFx (line 209) | def test_gridFx(self):
method test_gridFy (line 226) | def test_gridFy(self):
method test_gridFz (line 243) | def test_gridFz(self):
method test_gridEx (line 266) | def test_gridEx(self):
method test_gridEy (line 283) | def test_gridEy(self):
method test_gridEz (line 306) | def test_gridEz(self):
class TestCartesianGrid (line 329) | class TestCartesianGrid(unittest.TestCase):
method test_cartesianGrid (line 330) | def test_cartesianGrid(self):
class Deflation (line 356) | class Deflation(unittest.TestCase):
method test_areas (line 357) | def test_areas(self):
FILE: tests/cyl/test_cylOperators.py
class FaceInnerProductFctsIsotropic (line 41) | class FaceInnerProductFctsIsotropic(object):
method fcts (line 42) | def fcts(self):
method sol (line 62) | def sol(self):
method vectors (line 76) | def vectors(self, mesh):
class EdgeInnerProductFctsIsotropic (line 94) | class EdgeInnerProductFctsIsotropic(object):
method fcts (line 95) | def fcts(self):
method sol (line 115) | def sol(self):
method vectors (line 128) | def vectors(self, mesh):
class TestCylInnerProducts_simple (line 146) | class TestCylInnerProducts_simple(unittest.TestCase):
method setUp (line 147) | def setUp(self):
method test_FaceInnerProductIsotropic (line 151) | def test_FaceInnerProductIsotropic(self):
method test_EdgeInnerProduct (line 171) | def test_EdgeInnerProduct(self):
class TestCylFaceInnerProducts_Order (line 192) | class TestCylFaceInnerProducts_Order(tests.OrderTest):
method getError (line 196) | def getError(self):
method test_order (line 202) | def test_order(self):
class TestCylEdgeInnerProducts_Order (line 206) | class TestCylEdgeInnerProducts_Order(tests.OrderTest):
method getError (line 210) | def getError(self):
method test_order (line 216) | def test_order(self):
FILE: tests/cyl/test_cyl_counting.py
function test_pizza_slice_counting (line 5) | def test_pizza_slice_counting():
function test_ring_counting (line 104) | def test_ring_counting():
function test_cyl_tensor_counting (line 203) | def test_cyl_tensor_counting():
function test_sym_ring_counting (line 300) | def test_sym_ring_counting():
function test_sym_full_counting (line 358) | def test_sym_full_counting():
function test_wrapped_counting (line 417) | def test_wrapped_counting():
FILE: tests/cyl/test_cyl_innerproducts.py
class FaceInnerProductFctsIsotropic (line 15) | class FaceInnerProductFctsIsotropic(object):
method fcts (line 18) | def fcts(self):
method sol (line 31) | def sol(self):
method vectors (line 45) | def vectors(self, mesh):
class FaceInnerProductFunctionsDiagAnisotropic (line 61) | class FaceInnerProductFunctionsDiagAnisotropic(FaceInnerProductFctsIsotr...
method fcts (line 67) | def fcts(self):
method vectors (line 80) | def vectors(self, mesh):
class EdgeInnerProductFctsIsotropic (line 97) | class EdgeInnerProductFctsIsotropic(object):
method fcts (line 100) | def fcts(self):
method sol (line 108) | def sol(self):
method vectors (line 120) | def vectors(self, mesh):
class EdgeInnerProductFunctionsDiagAnisotropic (line 133) | class EdgeInnerProductFunctionsDiagAnisotropic(EdgeInnerProductFctsIsotr...
method vectors (line 139) | def vectors(self, mesh):
class FaceInnerProductFctsFacePropertiesIsotropic (line 151) | class FaceInnerProductFctsFacePropertiesIsotropic(object):
method fcts (line 154) | def fcts(self):
method sol (line 167) | def sol(self):
method vectors (line 180) | def vectors(self, mesh):
class EdgeInnerProductFctsFacePropertiesIsotropic (line 206) | class EdgeInnerProductFctsFacePropertiesIsotropic(object):
method fcts (line 209) | def fcts(self):
method sol (line 221) | def sol(self):
method vectors (line 243) | def vectors(self, mesh):
class TestCylInnerProducts_simple (line 267) | class TestCylInnerProducts_simple(unittest.TestCase):
method setUp (line 268) | def setUp(self):
method test_FaceInnerProductIsotropic (line 272) | def test_FaceInnerProductIsotropic(self):
method test_FaceInnerProductDiagAnisotropic (line 292) | def test_FaceInnerProductDiagAnisotropic(self):
method test_EdgeInnerProduct (line 312) | def test_EdgeInnerProduct(self):
method test_EdgeInnerProductDiagAnisotropic (line 332) | def test_EdgeInnerProductDiagAnisotropic(self):
method test_FaceInnerProductFacePropertiesIsotropic (line 353) | def test_FaceInnerProductFacePropertiesIsotropic(self):
method test_EdgeInnerProductFacePropertiesIsotropic (line 373) | def test_EdgeInnerProductFacePropertiesIsotropic(self):
class TestCylFaceInnerProducts_Order (line 394) | class TestCylFaceInnerProducts_Order(tests.OrderTest):
method getError (line 398) | def getError(self):
method test_order (line 404) | def test_order(self):
class TestCylEdgeInnerProducts_Order (line 408) | class TestCylEdgeInnerProducts_Order(tests.OrderTest):
method getError (line 412) | def getError(self):
method test_order (line 418) | def test_order(self):
class TestCylFaceInnerProductsDiagAnisotropic_Order (line 422) | class TestCylFaceInnerProductsDiagAnisotropic_Order(tests.OrderTest):
method getError (line 426) | def getError(self):
method test_order (line 432) | def test_order(self):
class TestCylFaceInnerProductsFaceProperties_Order (line 436) | class TestCylFaceInnerProductsFaceProperties_Order(tests.OrderTest):
method getError (line 440) | def getError(self):
method test_order (line 446) | def test_order(self):
class TestCylEdgeInnerProductsFaceProperties_Order (line 450) | class TestCylEdgeInnerProductsFaceProperties_Order(tests.OrderTest):
method getError (line 454) | def getError(self):
method test_order (line 460) | def test_order(self):
class TestCylInnerProducts_Deriv (line 464) | class TestCylInnerProducts_Deriv(unittest.TestCase):
method setUp (line 465) | def setUp(self):
method test_FaceInnerProductIsotropicDeriv (line 473) | def test_FaceInnerProductIsotropicDeriv(self):
method test_FaceInnerProductIsotropicDerivInvProp (line 486) | def test_FaceInnerProductIsotropicDerivInvProp(self):
method test_FaceInnerProductIsotropicDerivInvMat (line 501) | def test_FaceInnerProductIsotropicDerivInvMat(self):
method test_FaceInnerProductIsotropicDerivInvPropInvMat (line 516) | def test_FaceInnerProductIsotropicDerivInvPropInvMat(self):
method test_EdgeInnerProductIsotropicDeriv (line 533) | def test_EdgeInnerProductIsotropicDeriv(self):
method test_EdgeInnerProductIsotropicDerivInvProp (line 546) | def test_EdgeInnerProductIsotropicDerivInvProp(self):
method test_EdgeInnerProductIsotropicDerivInvMat (line 561) | def test_EdgeInnerProductIsotropicDerivInvMat(self):
method test_EdgeInnerProductIsotropicDerivInvPropInvMat (line 576) | def test_EdgeInnerProductIsotropicDerivInvPropInvMat(self):
class TestCylInnerProductsAnisotropic_Deriv (line 594) | class TestCylInnerProductsAnisotropic_Deriv(unittest.TestCase):
method setUp (line 595) | def setUp(self):
method test_FaceInnerProductAnisotropicDeriv (line 605) | def test_FaceInnerProductAnisotropicDeriv(self):
method test_FaceInnerProductAnisotropicDerivInvProp (line 627) | def test_FaceInnerProductAnisotropicDerivInvProp(self):
method test_FaceInnerProductAnisotropicDerivInvMat (line 647) | def test_FaceInnerProductAnisotropicDerivInvMat(self):
method test_FaceInnerProductAnisotropicDerivInvPropInvMat (line 667) | def test_FaceInnerProductAnisotropicDerivInvPropInvMat(self):
method test_EdgeInnerProductAnisotropicDeriv (line 691) | def test_EdgeInnerProductAnisotropicDeriv(self):
method test_EdgeInnerProductAnisotropicDerivInvProp (line 711) | def test_EdgeInnerProductAnisotropicDerivInvProp(self):
method test_EdgeInnerProductAnisotropicDerivInvMat (line 731) | def test_EdgeInnerProductAnisotropicDerivInvMat(self):
method test_EdgeInnerProductAnisotropicDerivInvPropInvMat (line 751) | def test_EdgeInnerProductAnisotropicDerivInvPropInvMat(self):
class TestCylInnerProductsFaceProperties_Deriv (line 776) | class TestCylInnerProductsFaceProperties_Deriv(unittest.TestCase):
method setUp (line 777) | def setUp(self):
method test_FaceInnerProductIsotropicDeriv (line 788) | def test_FaceInnerProductIsotropicDeriv(self):
method test_FaceInnerProductIsotropicDerivInvProp (line 801) | def test_FaceInnerProductIsotropicDerivInvProp(self):
method test_FaceInnerProductIsotropicDerivInvMat (line 816) | def test_FaceInnerProductIsotropicDerivInvMat(self):
method test_EdgeInnerProductIsotropicDeriv (line 831) | def test_EdgeInnerProductIsotropicDeriv(self):
method test_EdgeInnerProductIsotropicDerivInvProp (line 844) | def test_EdgeInnerProductIsotropicDerivInvProp(self):
method test_EdgeInnerProductIsotropicDerivInvMat (line 859) | def test_EdgeInnerProductIsotropicDerivInvMat(self):
FILE: tests/cyl/test_cyl_io.py
function test_convert_zero_wrapped_to_vtk (line 18) | def test_convert_zero_wrapped_to_vtk():
function test_convert_zero_nonwrapped_to_vtk (line 24) | def test_convert_zero_nonwrapped_to_vtk():
function test_convert_nonzero_wrapped_to_vtk (line 30) | def test_convert_nonzero_wrapped_to_vtk():
function test_convert_nonzero_nonwrapped_to_vtk (line 36) | def test_convert_nonzero_nonwrapped_to_vtk():
function test_convert_zero_wrapped_plot_grid (line 42) | def test_convert_zero_wrapped_plot_grid():
function test_convert_zero_nonwrapped_plot_grid (line 48) | def test_convert_zero_nonwrapped_plot_grid():
function test_convert_nonzero_wrapped_plot_grid (line 54) | def test_convert_nonzero_wrapped_plot_grid():
function test_convert_nonzero_nonwrapped_plot_grid (line 60) | def test_convert_nonzero_nonwrapped_plot_grid():
function cleanup_files (line 66) | def cleanup_files(monkeypatch):
FILE: tests/cyl/test_cyl_operators.py
function lambdify_vector (line 19) | def lambdify_vector(variabls, u_vecs, func):
function setup_mesh (line 62) | def setup_mesh(mesh_type, n):
function get_integration_limits (line 113) | def get_integration_limits(mesh_type):
function test_edge_curl (line 128) | def test_edge_curl(mesh_type):
function test_nodal_gradient (line 152) | def test_nodal_gradient(mesh_type):
function test_face_divergence (line 172) | def test_face_divergence(mesh_type):
function test_ave_edge_to_face (line 196) | def test_ave_edge_to_face(mesh_type):
function test_ave_edge_to_cell (line 214) | def test_ave_edge_to_cell(mesh_type):
function test_ave_face_to_cell (line 232) | def test_ave_face_to_cell(mesh_type):
function test_ave_cell_to_face (line 250) | def test_ave_cell_to_face(mesh_type):
function test_ave_node_to_cell (line 268) | def test_ave_node_to_cell(mesh_type):
function test_ave_node_to_face (line 286) | def test_ave_node_to_face(mesh_type):
function test_ave_face_to_cell_vector (line 304) | def test_ave_face_to_cell_vector(mesh_type):
function test_ave_edge_to_cell_vector (line 326) | def test_ave_edge_to_cell_vector(mesh_type):
function test_mimetic_div_curl (line 348) | def test_mimetic_div_curl(mesh_type):
function test_mimetic_curl_grad (line 357) | def test_mimetic_curl_grad(mesh_type):
function test_simple_edge_inner_product (line 366) | def test_simple_edge_inner_product(mesh_type):
function test_simple_face_inner_product (line 391) | def test_simple_face_inner_product(mesh_type):
function test_simple_edge_ave (line 416) | def test_simple_edge_ave(mesh_type):
function test_simple_face_ave (line 428) | def test_simple_face_ave(mesh_type):
function test_gradient_boundary_integral (line 440) | def test_gradient_boundary_integral(mesh_type):
function test_div_boundary_integral (line 479) | def test_div_boundary_integral(mesh_type):
function test_curl_boundary_integral (line 517) | def test_curl_boundary_integral(mesh_type):
function test_interpolation (line 568) | def test_interpolation(mesh_type, location_type):
FILE: tests/simplex/test_inner_products.py
function u (line 10) | def u(*args):
function v (line 21) | def v(*args):
function w (line 32) | def w(*args):
class TestInnerProducts2D (line 40) | class TestInnerProducts2D(discretize.tests.OrderTest):
method setupMesh (line 44) | def setupMesh(self, n):
method getError (line 49) | def getError(self):
method test_order1_edges (line 99) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 106) | def test_order1_edges_invert_model(self):
method test_order2_edges (line 113) | def test_order2_edges(self):
method test_order2_edges_invert_model (line 120) | def test_order2_edges_invert_model(self):
method test_order3_edges (line 127) | def test_order3_edges(self):
method test_order3_edges_invert_model (line 134) | def test_order3_edges_invert_model(self):
method test_order1_faces (line 141) | def test_order1_faces(self):
method test_order1_faces_invert_model (line 148) | def test_order1_faces_invert_model(self):
method test_order2_faces (line 155) | def test_order2_faces(self):
method test_order2_faces_invert_model (line 162) | def test_order2_faces_invert_model(self):
method test_order3_faces (line 169) | def test_order3_faces(self):
method test_order3_faces_invert_model (line 176) | def test_order3_faces_invert_model(self):
class TestInnerProducts3D (line 184) | class TestInnerProducts3D(discretize.tests.OrderTest):
method setupMesh (line 188) | def setupMesh(self, n):
method getError (line 193) | def getError(self):
method test_order1_edges (line 248) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 255) | def test_order1_edges_invert_model(self):
method test_order3_edges (line 262) | def test_order3_edges(self):
method test_order3_edges_invert_model (line 269) | def test_order3_edges_invert_model(self):
method test_order6_edges (line 276) | def test_order6_edges(self):
method test_order6_edges_invert_model (line 283) | def test_order6_edges_invert_model(self):
method test_order1_faces (line 290) | def test_order1_faces(self):
method test_order1_faces_invert_model (line 297) | def test_order1_faces_invert_model(self):
method test_order3_faces (line 304) | def test_order3_faces(self):
method test_order3_faces_invert_model (line 311) | def test_order3_faces_invert_model(self):
method test_order6_faces (line 318) | def test_order6_faces(self):
method test_order6_faces_invert_model (line 325) | def test_order6_faces_invert_model(self):
class TestInnerProductsDerivs (line 333) | class TestInnerProductsDerivs(unittest.TestCase):
method doTestFace (line 334) | def doTestFace(self, h, rep):
method doTestEdge (line 350) | def doTestEdge(self, h, rep):
method test_FaceIP_2D_float (line 366) | def test_FaceIP_2D_float(self):
method test_FaceIP_3D_float (line 369) | def test_FaceIP_3D_float(self):
method test_FaceIP_2D_isotropic (line 372) | def test_FaceIP_2D_isotropic(self):
method test_FaceIP_3D_isotropic (line 375) | def test_FaceIP_3D_isotropic(self):
method test_FaceIP_2D_anisotropic (line 378) | def test_FaceIP_2D_anisotropic(self):
method test_FaceIP_3D_anisotropic (line 381) | def test_FaceIP_3D_anisotropic(self):
method test_FaceIP_2D_tensor (line 384) | def test_FaceIP_2D_tensor(self):
method test_FaceIP_3D_tensor (line 387) | def test_FaceIP_3D_tensor(self):
method test_EdgeIP_2D_float (line 390) | def test_EdgeIP_2D_float(self):
method test_EdgeIP_3D_float (line 393) | def test_EdgeIP_3D_float(self):
method test_EdgeIP_2D_isotropic (line 396) | def test_EdgeIP_2D_isotropic(self):
method test_EdgeIP_3D_isotropic (line 399) | def test_EdgeIP_3D_isotropic(self):
method test_EdgeIP_2D_anisotropic (line 402) | def test_EdgeIP_2D_anisotropic(self):
method test_EdgeIP_3D_anisotropic (line 405) | def test_EdgeIP_3D_anisotropic(self):
method test_EdgeIP_2D_tensor (line 408) | def test_EdgeIP_2D_tensor(self):
method test_EdgeIP_3D_tensor (line 411) | def test_EdgeIP_3D_tensor(self):
class Test2DBoundaryIntegral (line 415) | class Test2DBoundaryIntegral(discretize.tests.OrderTest):
method setupMesh (line 419) | def setupMesh(self, n):
method getError (line 424) | def getError(self):
method test_orderWeakCellGradIntegral (line 463) | def test_orderWeakCellGradIntegral(self):
method test_orderWeakEdgeDivIntegral (line 468) | def test_orderWeakEdgeDivIntegral(self):
method test_orderWeakFaceCurlIntegral (line 473) | def test_orderWeakFaceCurlIntegral(self):
class Test3DBoundaryIntegral (line 479) | class Test3DBoundaryIntegral(discretize.tests.OrderTest):
method setupMesh (line 483) | def setupMesh(self, n):
method getError (line 488) | def getError(self):
method test_orderWeakCellGradIntegral (line 529) | def test_orderWeakCellGradIntegral(self):
method test_orderWeakEdgeDivIntegral (line 534) | def test_orderWeakEdgeDivIntegral(self):
method test_orderWeakFaceCurlIntegral (line 539) | def test_orderWeakFaceCurlIntegral(self):
class TestBadModels (line 545) | class TestBadModels(unittest.TestCase):
method setUp (line 546) | def setUp(self):
method test_bad_model_size (line 551) | def test_bad_model_size(self):
method test_cant_invert (line 559) | def test_cant_invert(self):
FILE: tests/simplex/test_interpolation.py
class TestInterpolation2d (line 6) | class TestInterpolation2d(discretize.tests.OrderTest):
method setupMesh (line 16) | def setupMesh(self, n):
method getError (line 21) | def getError(self):
method test_orderCC (line 49) | def test_orderCC(self):
method test_orderN (line 56) | def test_orderN(self):
method test_orderFx (line 63) | def test_orderFx(self):
method test_orderFy (line 68) | def test_orderFy(self):
method test_orderEx (line 73) | def test_orderEx(self):
method test_orderEy (line 78) | def test_orderEy(self):
class TestInterpolation3d (line 84) | class TestInterpolation3d(discretize.tests.OrderTest):
method setupMesh (line 94) | def setupMesh(self, n):
method getError (line 99) | def getError(self):
method test_orderCC (line 138) | def test_orderCC(self):
method test_orderN (line 145) | def test_orderN(self):
method test_orderFx (line 152) | def test_orderFx(self):
method test_orderFy (line 157) | def test_orderFy(self):
method test_orderFz (line 162) | def test_orderFz(self):
method test_orderEx (line 167) | def test_orderEx(self):
method test_orderEy (line 172) | def test_orderEy(self):
method test_orderEz (line 177) | def test_orderEz(self):
class TestAveraging (line 183) | class TestAveraging(discretize.tests.OrderTest):
method setupMesh (line 187) | def setupMesh(self, n):
method getError (line 193) | def getError(self):
method test_AvgN2CC_2D (line 256) | def test_AvgN2CC_2D(self):
method test_AvgN2F_2D (line 264) | def test_AvgN2F_2D(self):
method test_AvgN2E_2D (line 272) | def test_AvgN2E_2D(self):
method test_AvgCC2E_2D (line 280) | def test_AvgCC2E_2D(self):
method test_AvgE2CC_2D (line 288) | def test_AvgE2CC_2D(self):
method test_AvgF2CC_2D (line 296) | def test_AvgF2CC_2D(self):
method test_AvgCC2F_2D (line 304) | def test_AvgCC2F_2D(self):
method test_AvgN2CC_3D (line 313) | def test_AvgN2CC_3D(self):
method test_AvgN2F_3D (line 321) | def test_AvgN2F_3D(self):
method test_AvgN2E_3D (line 329) | def test_AvgN2E_3D(self):
method test_AvgCC2N_3D (line 337) | def test_AvgCC2N_3D(self):
method test_AvgE2CC_3D (line 345) | def test_AvgE2CC_3D(self):
method test_AvgF2CC_3D (line 353) | def test_AvgF2CC_3D(self):
method test_AvgCC2F_3D (line 361) | def test_AvgCC2F_3D(self):
class TestVectorAveraging2D (line 370) | class TestVectorAveraging2D(discretize.tests.OrderTest):
method setupMesh (line 377) | def setupMesh(self, n):
method getError (line 382) | def getError(self):
method test_AvgE2CCV (line 402) | def test_AvgE2CCV(self):
method test_AvgF2CCV (line 407) | def test_AvgF2CCV(self):
class TestVectorAveraging3D (line 413) | class TestVectorAveraging3D(discretize.tests.OrderTest):
method setupMesh (line 420) | def setupMesh(self, n):
method getError (line 425) | def getError(self):
method test_AvgE2CCV (line 448) | def test_AvgE2CCV(self):
method test_AvgF2CCV (line 454) | def test_AvgF2CCV(self):
function test_cell_to_face_extrap (line 461) | def test_cell_to_face_extrap():
function test_zeros_outside (line 483) | def test_zeros_outside():
FILE: tests/simplex/test_operators.py
class TestOperators2D (line 9) | class TestOperators2D(discretize.tests.OrderTest):
method setupMesh (line 13) | def setupMesh(self, n):
method getError (line 18) | def getError(self):
method test_curl_order (line 67) | def test_curl_order(self):
method test_div_order (line 72) | def test_div_order(self):
method test_grad_order (line 77) | def test_grad_order(self):
method test_cell_gradient_stencil (line 82) | def test_cell_gradient_stencil(self):
class TestOperators3D (line 100) | class TestOperators3D(discretize.tests.OrderTest):
method setupMesh (line 104) | def setupMesh(self, n):
method getError (line 112) | def getError(self):
method test_curl_order (line 171) | def test_curl_order(self):
method test_div_order (line 176) | def test_div_order(self):
method test_grad_order (line 181) | def test_grad_order(self):
function test_simplex_projection_caching (line 188) | def test_simplex_projection_caching(i_type):
FILE: tests/simplex/test_utils.py
class SimplexTests (line 22) | class SimplexTests(unittest.TestCase):
method test_init_errors (line 23) | def test_init_errors(self):
method test_find_containing (line 52) | def test_find_containing(self):
method test_pickle2D (line 62) | def test_pickle2D(self):
method test_pickle3D (line 73) | def test_pickle3D(self):
method test_image_plotting (line 85) | def test_image_plotting(self):
method test_plot_grid (line 121) | def test_plot_grid(self):
method test_2D_vtk (line 133) | def test_2D_vtk(self):
method test_3D_vtk (line 155) | def test_3D_vtk(self):
method tearDown (line 176) | def tearDown(self):
FILE: tests/tree/test_intersections.py
function test_point_locator (line 9) | def test_point_locator(dim):
function test_ball_locator (line 20) | def test_ball_locator(dim):
function test_line_locator (line 46) | def test_line_locator(dim):
function test_box_locator (line 65) | def test_box_locator(dim):
function test_plane_locator (line 86) | def test_plane_locator(dim):
function test_triangle_locator (line 122) | def test_triangle_locator(dim):
function test_vert_tri_prism_locator (line 149) | def test_vert_tri_prism_locator(dim):
function test_tetrahedron_locator (line 194) | def test_tetrahedron_locator(dim):
FILE: tests/tree/test_refine.py
function test_2d_line (line 9) | def test_2d_line():
function test_3d_line (line 26) | def test_3d_line():
function test_line_errors (line 43) | def test_line_errors():
function test_triangle2d (line 59) | def test_triangle2d():
function test_triangle3d (line 77) | def test_triangle3d():
function test_triangle_errors (line 96) | def test_triangle_errors():
function test_tetra2d (line 117) | def test_tetra2d():
function test_tetra3d (line 137) | def test_tetra3d():
function test_tetra_errors (line 163) | def test_tetra_errors():
function test_box_errors (line 184) | def test_box_errors():
function test_ball_errors (line 211) | def test_ball_errors():
function test_insert_errors (line 229) | def test_insert_errors():
function test_refine_triang_prism (line 243) | def test_refine_triang_prism():
function test_refine_triang_prism_errors (line 281) | def test_refine_triang_prism_errors():
function test_bounding_box (line 317) | def test_bounding_box():
function test_bounding_box_errors (line 351) | def test_bounding_box_errors():
function test_refine_points (line 364) | def test_refine_points():
function test_refine_points_errors (line 389) | def test_refine_points_errors():
function test_refine_surface2D (line 398) | def test_refine_surface2D():
function test_refine_surface3D (line 428) | def test_refine_surface3D():
function test_refine_surface_errors (line 453) | def test_refine_surface_errors():
function test_refine_plane2D (line 464) | def test_refine_plane2D():
function test_refine_plane3D (line 478) | def test_refine_plane3D():
function _make_quadrant_model (line 497) | def _make_quadrant_model(mesh, order):
function test_refine_image_input_ordering (line 538) | def test_refine_image_input_ordering(tens_inp):
function test_refine_image (line 595) | def test_refine_image(tens_inp, model_func):
function test_refine_image_bad_size (line 618) | def test_refine_image_bad_size():
function test_refine_image_bad_shape (line 631) | def test_refine_image_bad_shape():
FILE: tests/tree/test_safeguards.py
function mesh (line 64) | def mesh():
function refine_mesh (line 73) | def refine_mesh(mesh):
class TestSafeGuards (line 85) | class TestSafeGuards:
method test_errors (line 89) | def test_errors(self, mesh, prop_name, refine):
method test_no_errors (line 102) | def test_no_errors(self, mesh, prop_name):
method test_errors_inherited_properties (line 114) | def test_errors_inherited_properties(self, mesh, prop_name, refine):
FILE: tests/tree/test_tree.py
class TestSimpleQuadTree (line 11) | class TestSimpleQuadTree(unittest.TestCase):
method test_counts (line 12) | def test_counts(self):
method test_getitem (line 30) | def test_getitem(self):
method test_getitem3D (line 40) | def test_getitem3D(self):
method test_refine (line 51) | def test_refine(self):
method test_h_gridded_2D (line 56) | def test_h_gridded_2D(self):
method test_faceDiv (line 90) | def test_faceDiv(self):
method test_serialization (line 120) | def test_serialization(self):
class TestOcTree (line 134) | class TestOcTree(unittest.TestCase):
method test_counts (line 135) | def test_counts(self):
method test_faceDiv (line 161) | def test_faceDiv(self):
method test_edge_curl (line 182) | def test_edge_curl(self):
method test_faceInnerProduct (line 193) | def test_faceInnerProduct(self):
method test_VectorIdenties (line 215) | def test_VectorIdenties(self):
method test_h_gridded_3D (line 235) | def test_h_gridded_3D(self):
method test_cell_nodes (line 313) | def test_cell_nodes(self):
class TestTreeMeshNodes (line 346) | class TestTreeMeshNodes:
method sample_mesh (line 348) | def sample_mesh(self, request):
method test_total_nodes (line 368) | def test_total_nodes(self, sample_mesh):
class TestTreeCellBounds (line 383) | class TestTreeCellBounds:
method mesh (line 387) | def mesh(self, request):
method test_bounds (line 406) | def test_bounds(self, mesh):
method test_bounds_relations (line 419) | def test_bounds_relations(self, mesh):
method test_cell_bounds (line 432) | def test_cell_bounds(self, mesh):
class TestWrapAroundLevels (line 441) | class TestWrapAroundLevels(unittest.TestCase):
method test_refine_func (line 442) | def test_refine_func(self):
method test_refine_box (line 451) | def test_refine_box(self):
method test_refine_ball (line 462) | def test_refine_ball(self):
method test_insert_point (line 473) | def test_insert_point(self):
function test_cell_locator (line 484) | def test_cell_locator(dim):
class TestRepr (line 500) | class TestRepr:
method mesh (line 509) | def mesh(self, request):
method finalize (line 521) | def finalize(self, mesh):
method test_repr (line 537) | def test_repr(self, mesh, finalize):
method test_repr_html (line 548) | def test_repr_html(self, mesh, finalize):
function test_caching (line 560) | def test_caching(attr):
FILE: tests/tree/test_tree_balancing.py
function check_for_diag_unbalance (line 5) | def check_for_diag_unbalance(mesh):
function test_insert_cells_2D (line 18) | def test_insert_cells_2D():
function test_insert_cells_3D (line 38) | def test_insert_cells_3D():
function test_refine (line 66) | def test_refine():
function test_refine_box (line 86) | def test_refine_box():
function test_refine_ball (line 100) | def test_refine_ball():
function test_refine_line (line 114) | def test_refine_line():
function test_refine_triangle (line 130) | def test_refine_triangle():
function test_refine_tetra (line 145) | def test_refine_tetra():
function test_balance_out_unbalance_in (line 162) | def test_balance_out_unbalance_in():
FILE: tests/tree/test_tree_innerproduct_derivs.py
class TestInnerProductsDerivsTensor (line 8) | class TestInnerProductsDerivsTensor(unittest.TestCase):
method doTestFace (line 9) | def doTestFace(
method doTestEdge (line 47) | def doTestEdge(
method test_FaceIP_2D_float_Tree (line 85) | def test_FaceIP_2D_float_Tree(self):
method test_FaceIP_3D_float_Tree (line 88) | def test_FaceIP_3D_float_Tree(self):
method test_FaceIP_2D_isotropic_Tree (line 91) | def test_FaceIP_2D_isotropic_Tree(self):
method test_FaceIP_3D_isotropic_Tree (line 94) | def test_FaceIP_3D_isotropic_Tree(self):
method test_FaceIP_2D_anisotropic_Tree (line 97) | def test_FaceIP_2D_anisotropic_Tree(self):
method test_FaceIP_3D_anisotropic_Tree (line 100) | def test_FaceIP_3D_anisotropic_Tree(self):
method test_FaceIP_2D_tensor_Tree (line 103) | def test_FaceIP_2D_tensor_Tree(self):
method test_FaceIP_3D_tensor_Tree (line 106) | def test_FaceIP_3D_tensor_Tree(self):
method test_FaceIP_2D_float_fast_Tree (line 109) | def test_FaceIP_2D_float_fast_Tree(self):
method test_FaceIP_3D_float_fast_Tree (line 112) | def test_FaceIP_3D_float_fast_Tree(self):
method test_FaceIP_2D_isotropic_fast_Tree (line 115) | def test_FaceIP_2D_isotropic_fast_Tree(self):
method test_FaceIP_3D_isotropic_fast_Tree (line 118) | def test_FaceIP_3D_isotropic_fast_Tree(self):
method test_FaceIP_2D_anisotropic_fast_Tree (line 121) | def test_FaceIP_2D_anisotropic_fast_Tree(self):
method test_FaceIP_3D_anisotropic_fast_Tree (line 124) | def test_FaceIP_3D_anisotropic_fast_Tree(self):
method test_EdgeIP_3D_float_Tree (line 129) | def test_EdgeIP_3D_float_Tree(self):
method test_EdgeIP_3D_isotropic_Tree (line 135) | def test_EdgeIP_3D_isotropic_Tree(self):
method test_EdgeIP_3D_anisotropic_Tree (line 141) | def test_EdgeIP_3D_anisotropic_Tree(self):
method test_EdgeIP_3D_tensor_Tree (line 147) | def test_EdgeIP_3D_tensor_Tree(self):
method test_EdgeIP_3D_float_fast_Tree (line 152) | def test_EdgeIP_3D_float_fast_Tree(self):
method test_EdgeIP_3D_isotropic_fast_Tree (line 158) | def test_EdgeIP_3D_isotropic_fast_Tree(self):
method test_EdgeIP_3D_anisotropic_fast_Tree (line 164) | def test_EdgeIP_3D_anisotropic_fast_Tree(self):
class TestFacePropertiesInnerProductsDerivsTensor (line 168) | class TestFacePropertiesInnerProductsDerivsTensor(unittest.TestCase):
method doTestFace (line 169) | def doTestFace(self, h, rep, meshType, invert_model=False, invert_matr...
method doTestEdge (line 204) | def doTestEdge(self, h, rep, meshType, invert_model=False, invert_matr...
method test_FaceIP_2D_float_fast_Tree (line 239) | def test_FaceIP_2D_float_fast_Tree(self):
method test_FaceIP_3D_float_fast_Tree (line 242) | def test_FaceIP_3D_float_fast_Tree(self):
method test_FaceIP_2D_isotropic_fast_Tree (line 245) | def test_FaceIP_2D_isotropic_fast_Tree(self):
method test_FaceIP_3D_isotropic_fast_Tree (line 248) | def test_FaceIP_3D_isotropic_fast_Tree(self):
method test_EdgeIP_2D_float_fast_Tree (line 251) | def test_EdgeIP_2D_float_fast_Tree(self):
method test_EdgeIP_3D_float_fast_Tree (line 254) | def test_EdgeIP_3D_float_fast_Tree(self):
method test_EdgeIP_2D_isotropic_fast_Tree (line 257) | def test_EdgeIP_2D_isotropic_fast_Tree(self):
method test_EdgeIP_3D_isotropic_fast_Tree (line 260) | def test_EdgeIP_3D_isotropic_fast_Tree(self):
class TestEdgePropertiesInnerProductsDerivsTensor (line 264) | class TestEdgePropertiesInnerProductsDerivsTensor(unittest.TestCase):
method doTestEdge (line 265) | def doTestEdge(self, h, rep, meshType, invert_model=False, invert_matr...
method test_EdgeIP_2D_float_fast_Tree (line 300) | def test_EdgeIP_2D_float_fast_Tree(self):
method test_EdgeIP_3D_float_fast_Tree (line 303) | def test_EdgeIP_3D_float_fast_Tree(self):
method test_EdgeIP_2D_isotropic_fast_Tree (line 306) | def test_EdgeIP_2D_isotropic_fast_Tree(self):
method test_EdgeIP_3D_isotropic_fast_Tree (line 309) | def test_EdgeIP_3D_isotropic_fast_Tree(self):
FILE: tests/tree/test_tree_interpolation.py
function test_order (line 56) | def test_order(tree_type, dim, mesh_locs, zeros_outside):
function ana_func (line 78) | def ana_func(locs):
function order_func (line 90) | def order_func(n):
function test_zeros_outside (line 122) | def test_zeros_outside(dim, mesh_locs):
function test_project_outside (line 172) | def test_project_outside(dim, mesh_locs):
function ana_func (line 199) | def ana_func(locs):
FILE: tests/tree/test_tree_io.py
function mesh (line 17) | def mesh(request):
function test_UBCfiles (line 32) | def test_UBCfiles(mesh, tmp_path):
function test_ubc_files_no_warning_diagonal_balance (line 53) | def test_ubc_files_no_warning_diagonal_balance(mesh, tmp_path):
function test_write_VTU_files (line 68) | def test_write_VTU_files(mesh, tmp_path):
function test_pickle (line 74) | def test_pickle(mesh):
function test_dic_serialize (line 82) | def test_dic_serialize(mesh):
function test_json_serialize (line 89) | def test_json_serialize(mesh, tmp_path):
FILE: tests/tree/test_tree_operators.py
class TestCellGrad2D (line 34) | class TestCellGrad2D(discretize.tests.OrderTest):
method getError (line 42) | def getError(self):
method test_order (line 57) | def test_order(self):
class TestCellGrad3D (line 61) | class TestCellGrad3D(discretize.tests.OrderTest):
method getError (line 69) | def getError(self):
method test_order (line 106) | def test_order(self):
class TestFaceDivxy2D (line 110) | class TestFaceDivxy2D(discretize.tests.OrderTest):
method getError (line 116) | def getError(self):
method test_order (line 136) | def test_order(self):
class TestFaceDiv3D (line 140) | class TestFaceDiv3D(discretize.tests.OrderTest):
method getError (line 145) | def getError(self):
method test_order (line 163) | def test_order(self):
class TestFaceDivxyz3D (line 167) | class TestFaceDivxyz3D(discretize.tests.OrderTest):
method getError (line 173) | def getError(self):
method test_order (line 200) | def test_order(self):
class TestCurl (line 204) | class TestCurl(discretize.tests.OrderTest):
method getError (line 210) | def getError(self):
method test_order (line 235) | def test_order(self):
class TestNodalGrad (line 239) | class TestNodalGrad(discretize.tests.OrderTest):
method getError (line 245) | def getError(self):
method test_order (line 263) | def test_order(self):
class TestNodalGrad2D (line 267) | class TestNodalGrad2D(discretize.tests.OrderTest):
method getError (line 274) | def getError(self):
method test_order (line 291) | def test_order(self):
class TestTreeInnerProducts (line 295) | class TestTreeInnerProducts(discretize.tests.OrderTest):
method getError (line 305) | def getError(self):
method test_order1_edges (line 371) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 378) | def test_order1_edges_invert_model(self):
method test_order3_edges (line 385) | def test_order3_edges(self):
method test_order3_edges_invert_model (line 392) | def test_order3_edges_invert_model(self):
method test_order6_edges (line 399) | def test_order6_edges(self):
method test_order6_edges_invert_model (line 406) | def test_order6_edges_invert_model(self):
method test_order1_faces (line 413) | def test_order1_faces(self):
method test_order1_faces_invert_model (line 420) | def test_order1_faces_invert_model(self):
method test_order3_faces (line 427) | def test_order3_faces(self):
method test_order3_faces_invert_model (line 434) | def test_order3_faces_invert_model(self):
method test_order6_faces (line 441) | def test_order6_faces(self):
method test_order6_faces_invert_model (line 448) | def test_order6_faces_invert_model(self):
class TestInnerProductsFaceProperties3D (line 456) | class TestInnerProductsFaceProperties3D(discretize.tests.OrderTest):
method getError (line 464) | def getError(self):
method test_order1_edges (line 525) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 531) | def test_order1_edges_invert_model(self):
method test_order1_faces (line 537) | def test_order1_faces(self):
method test_order1_faces_invert_model (line 543) | def test_order1_faces_invert_model(self):
class TestInnerProductsEdgeProperties3D (line 550) | class TestInnerProductsEdgeProperties3D(discretize.tests.OrderTest):
method getError (line 558) | def getError(self):
method test_order1_edges (line 601) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 607) | def test_order1_edges_invert_model(self):
class TestTreeInnerProducts2D (line 614) | class TestTreeInnerProducts2D(discretize.tests.OrderTest):
method getError (line 621) | def getError(self):
method test_order1_edges (line 673) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 680) | def test_order1_edges_invert_model(self):
method test_order3_edges (line 687) | def test_order3_edges(self):
method test_order3_edges_invert_model (line 694) | def test_order3_edges_invert_model(self):
method test_order1_faces (line 715) | def test_order1_faces(self):
method test_order1_faces_invert_model (line 722) | def test_order1_faces_invert_model(self):
method test_order2_faces (line 729) | def test_order2_faces(self):
method test_order2_faces_invert_model (line 736) | def test_order2_faces_invert_model(self):
method test_order3_faces (line 743) | def test_order3_faces(self):
method test_order3_faces_invert_model (line 750) | def test_order3_faces_invert_model(self):
class TestInnerProductsFaceProperties2D (line 758) | class TestInnerProductsFaceProperties2D(discretize.tests.OrderTest):
method getError (line 766) | def getError(self):
method test_order1_edges (line 823) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 829) | def test_order1_edges_invert_model(self):
method test_order1_faces (line 835) | def test_order1_faces(self):
method test_order1_faces_invert_model (line 841) | def test_order1_faces_invert_model(self):
class TestInnerProductsEdgeProperties2D (line 848) | class TestInnerProductsEdgeProperties2D(discretize.tests.OrderTest):
method getError (line 856) | def getError(self):
method test_order1_edges (line 897) | def test_order1_edges(self):
method test_order1_edges_invert_model (line 903) | def test_order1_edges_invert_model(self):
class TestTreeAveraging2D (line 910) | class TestTreeAveraging2D(discretize.tests.OrderTest):
method getError (line 918) | def getError(self):
method test_orderN2CC (line 923) | def test_orderN2CC(self):
method test_orderN2Fx (line 931) | def test_orderN2Fx(self):
method test_orderN2E (line 939) | def test_orderN2E(self):
method test_orderF2CC (line 947) | def test_orderF2CC(self):
method test_orderFx2CC (line 955) | def test_orderFx2CC(self):
method test_orderFy2CC (line 963) | def test_orderFy2CC(self):
method test_orderF2CCV (line 971) | def test_orderF2CCV(self):
method test_orderCC2F (line 980) | def test_orderCC2F(self):
class TestAveraging3D (line 991) | class TestAveraging3D(discretize.tests.OrderTest):
method getError (line 998) | def getError(self):
method test_orderN2CC (line 1003) | def test_orderN2CC(self):
method test_orderN2F (line 1011) | def test_orderN2F(self):
method test_orderN2E (line 1021) | def test_orderN2E(self):
method test_orderF2CC (line 1031) | def test_orderF2CC(self):
method test_orderFx2CC (line 1041) | def test_orderFx2CC(self):
method test_orderFy2CC (line 1049) | def test_orderFy2CC(self):
method test_orderFz2CC (line 1057) | def test_orderFz2CC(self):
method test_orderF2CCV (line 1065) | def test_orderF2CCV(self):
method test_orderEx2CC (line 1079) | def test_orderEx2CC(self):
method test_orderEy2CC (line 1087) | def test_orderEy2CC(self):
method test_orderEz2CC (line 1095) | def test_orderEz2CC(self):
method test_orderE2CC (line 1103) | def test_orderE2CC(self):
method test_orderE2CCV (line 1113) | def test_orderE2CCV(self):
method test_orderCC2F (line 1127) | def test_orderCC2F(self):
FILE: tests/tree/test_tree_plotting.py
class TestOcTreePlotting (line 19) | class TestOcTreePlotting(unittest.TestCase):
method setUp (line 20) | def setUp(self):
method test_plot_slice (line 25) | def test_plot_slice(self):
class TestQuadTreePlotting (line 68) | class TestQuadTreePlotting(unittest.TestCase):
method setUp (line 69) | def setUp(self):
method test_plot_slice (line 74) | def test_plot_slice(self):
FILE: tests/tree/test_tree_utils.py
class TestRefineOcTree (line 8) | class TestRefineOcTree(unittest.TestCase):
method test_radial (line 9) | def test_radial(self):
method test_box (line 42) | def test_box(self):
method test_surface (line 72) | def test_surface(self):
method test_errors (line 111) | def test_errors(self):
FILE: tests/tree/test_tree_vtk.py
class TestTreeMeshVTK (line 15) | class TestTreeMeshVTK(unittest.TestCase):
method setUp (line 16) | def setUp(self):
method test_VTK_object_conversion (line 24) | def test_VTK_object_conversion(self):
FILE: tutorials/inner_products/1_basic.py
function fcn_gaussian (line 107) | def fcn_gaussian(x, mu, sig):
function fcn_x (line 169) | def fcn_x(xy, sig):
function fcn_y (line 175) | def fcn_y(xy, sig):
FILE: tutorials/mesh_generation/1_mesh_overview.py
function refine (line 39) | def refine(cell):
FILE: tutorials/operators/1_averaging.py
function fun (line 55) | def fun(x):
FILE: tutorials/pde/3_nodal_dirichlet_poisson.py
function get_error (line 134) | def get_error(n_cells, plot_it=False):
Condensed preview — 214 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,348K chars).
[
{
"path": ".ci/azure/deploy.yml",
"chars": 1695,
"preview": "jobs:\n- job:\n displayName: \"Deploy Docs\"\n pool:\n vmImage: ubuntu-latest\n\n steps:\n # No need to checkout the rep"
},
{
"path": ".ci/azure/docs.yml",
"chars": 837,
"preview": "jobs:\n- job: BuildDocs\n displayName: \"Build Documentation\"\n pool:\n vmImage: ubuntu-latest\n variables:\n python.v"
},
{
"path": ".ci/azure/run_tests.sh",
"chars": 669,
"preview": "#!/bin/bash\nset -ex #echo on and exit if any line fails\n\n# TF_BUILD is set to True on azure pipelines.\nis_azure=$(echo \""
},
{
"path": ".ci/azure/sdist.yml",
"chars": 625,
"preview": "jobs:\n- job:\n displayName: \"Build source dist.\"\n pool:\n vmImage: ubuntu-latest\n steps:\n - task: UsePythonVersio"
},
{
"path": ".ci/azure/setup_env.sh",
"chars": 1678,
"preview": "#!/bin/bash\nset -ex #echo on and exit if any line fails\n\n# TF_BUILD is set to True on azure pipelines.\nis_azure=$(echo \""
},
{
"path": ".ci/azure/setup_miniconda_macos.sh",
"chars": 495,
"preview": "#!/bin/bash\nset -ex #echo on and exit if any line fails\n\necho \"arch is $ARCH\"\nif [[ $ARCH == \"X64\" ]]; then\n MINICONDA_"
},
{
"path": ".ci/azure/style.yml",
"chars": 702,
"preview": "jobs:\n - job:\n displayName: Run style checks with Black\n pool:\n vmImage: ubuntu-latest\n steps:\n - ta"
},
{
"path": ".ci/azure/test.yml",
"chars": 2968,
"preview": "jobs:\n- job:\n strategy:\n matrix:\n linux-Python311:\n image: ubuntu-latest\n python.version: '3.11'\n"
},
{
"path": ".ci/environment_test.yml",
"chars": 471,
"preview": "name: discretize-test\nchannels:\n - conda-forge\ndependencies:\n - numpy>=1.22.4\n - scipy>=1.8\n\n # optionals\n - vtk>=6"
},
{
"path": ".ci/environment_test_bare.yml",
"chars": 249,
"preview": "name: discretize-test\nchannels:\n - conda-forge\ndependencies:\n - numpy>=1.22.4\n - scipy>=1.12\n\n # testing\n - sympy\n "
},
{
"path": ".ci/install_style.sh",
"chars": 318,
"preview": "#!/bin/bash\nset -ex #echo on and exit if any line fails\n\n# get directory of this script\nscript_dir=$( cd -- \"$( dirname "
},
{
"path": ".ci/parse_style_requirements.py",
"chars": 328,
"preview": "import tomllib\nimport pathlib\n\nroot_dir = pathlib.Path(__file__).parent.parent.resolve()\npyproject_file = root_dir / \"py"
},
{
"path": ".ci/setup_headless_display.sh",
"chars": 691,
"preview": "#!/bin/sh\nset -x\n\nsudo apt update\n# Install items for headless pyvista display.\nsudo apt-get install -y \\\n libglx-mesa0"
},
{
"path": ".git_archival.txt",
"chars": 124,
"preview": "node: $Format:%H$\nnode-date: $Format:%cI$\ndescribe-name: $Format:%(describe:tags=true,match=*[0-9]*)$\nref-names: $Format"
},
{
"path": ".gitattributes",
"chars": 384,
"preview": ".git_archival.txt export-subst\n# Excluding files from an sdist generated by meson-python\n\n.azure-pipelines/* export-ign"
},
{
"path": ".github/workflows/build_distributions.yml",
"chars": 1596,
"preview": "name: Build Distribution artifacts\n\non: [push, pull_request]\n\njobs:\n build_wheels:\n name: Build wheels on ${{ matrix"
},
{
"path": ".gitignore",
"chars": 792,
"preview": "*.py[cod]\n\n# C extensions\n*.so\n\n# Packages\n*.egg\n*.egg-info\ndist\nbuild\neggs\n.eggs\nparts\nbin\nvar\nsdist\ndevelop-eggs\n.inst"
},
{
"path": ".pre-commit-config.yaml",
"chars": 521,
"preview": "repos:\n - repo: https://github.com/psf/black-pre-commit-mirror\n rev: 24.3.0\n hooks:\n - id: black\n lan"
},
{
"path": "AUTHORS.rst",
"chars": 1107,
"preview": "- Rowan Cockett, (`@rowanc1 <https://github.com/rowanc1/>`_)\n- Lindsey Heagy, (`@lheagy <https://github.com/lheagy/>`_)\n"
},
{
"path": "CITATION.rst",
"chars": 849,
"preview": "Citing discretize\n-----------------\n\nThere is a `paper about discretize <http://dx.doi.org/10.1016/j.cageo.2015.09.015>`"
},
{
"path": "LICENSE",
"chars": 1089,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2013-2025 SimPEG Developers\n\nPermission is hereby granted, free of charge, to any p"
},
{
"path": "README.rst",
"chars": 3897,
"preview": ".. image:: https://raw.github.com/simpeg/discretize/main/docs/images/discretize-logo.png\n :alt: Discretize Logo\n\ndisc"
},
{
"path": "azure-pipelines.yml",
"chars": 912,
"preview": "trigger:\n branches:\n include:\n - 'main'\n exclude:\n - '*no-ci*'\n tags:\n include:\n - '*'\n\npr:\n branch"
},
{
"path": "discretize/Tests/__init__.py",
"chars": 366,
"preview": "from discretize.tests import * # NOQA F401,F403\nfrom discretize.utils.code_utils import deprecate_module\n\n# note this n"
},
{
"path": "discretize/Tests/meson.build",
"chars": 109,
"preview": "\npython_sources = [\n '__init__.py',\n]\n\npy.install_sources(\n python_sources,\n subdir: 'discretize/Tests'\n)\n"
},
{
"path": "discretize/View.py",
"chars": 306,
"preview": "\"\"\"Deprecated view module.\"\"\"\n\nfrom discretize.utils.code_utils import deprecate_module\n\ndeprecate_module(\n \"discreti"
},
{
"path": "discretize/__init__.py",
"chars": 2898,
"preview": "\"\"\"\n=====================================\nDiscretize Meshes (:mod:`discretize`)\n=====================================\n.."
},
{
"path": "discretize/_extensions/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "discretize/_extensions/geom.cpp",
"chars": 17959,
"preview": "#include <algorithm>\n#include <limits>\n#include \"geom.h\"\n#include <algorithm>\n#include <limits>\n\n// Define the 3D cross "
},
{
"path": "discretize/_extensions/geom.h",
"chars": 2243,
"preview": "#ifndef __GEOM_H\n#define __GEOM_H\n// simple geometric objects for intersection tests with an aabb\n\ntypedef std::size_t i"
},
{
"path": "discretize/_extensions/geom.pxd",
"chars": 977,
"preview": "from libcpp cimport bool\n\ncdef extern from \"geom.h\":\n ctypedef int int_t\n cdef cppclass Ball:\n Ball() excep"
},
{
"path": "discretize/_extensions/interputils_cython.pxd",
"chars": 161,
"preview": "cimport numpy as np\ncdef np.int64_t _bisect_left(np.float64_t[:] a, np.float64_t x) nogil\ncdef np.int64_t _bisect_right("
},
{
"path": "discretize/_extensions/interputils_cython.pyx",
"chars": 10763,
"preview": "# cython: embedsignature=True, language_level=3\n# cython: linetrace=True\n# cython: freethreading_compatible = True\nimpor"
},
{
"path": "discretize/_extensions/meson.build",
"chars": 1753,
"preview": "# NumPy include directory\nnumpy_nodepr_api = ['-DNPY_NO_DEPRECATED_API=NPY_1_22_API_VERSION']\nnp_dep = dependency('numpy"
},
{
"path": "discretize/_extensions/simplex_helpers.pyx",
"chars": 13029,
"preview": "# distutils: language=c++\n# cython: embedsignature=True, language_level=3\n# cython: linetrace=True\n# cython: freethreadi"
},
{
"path": "discretize/_extensions/tree.cpp",
"chars": 55126,
"preview": "#include <vector>\n#include <map>\n#include \"tree.h\"\n#include \"geom.h\"\n#include <iostream>\n#include <algorithm>\n#include <"
},
{
"path": "discretize/_extensions/tree.h",
"chars": 7129,
"preview": "#ifndef __TREE_H\r\n#define __TREE_H\r\n\r\n#include <vector>\r\n#include <map>\r\n#include <iostream>\r\n#include <algorithm>\r\n\r\n#i"
},
{
"path": "discretize/_extensions/tree.pxd",
"chars": 2834,
"preview": "from libcpp cimport bool\nfrom libcpp.vector cimport vector\nfrom libcpp.map cimport map\n\ncdef extern from \"tree.h\":\n c"
},
{
"path": "discretize/_extensions/tree_ext.pyx",
"chars": 274154,
"preview": "# distutils: language=c++\n# cython: embedsignature=True, language_level=3\n# cython: linetrace=True\n# cython: freethreadi"
},
{
"path": "discretize/_extensions/triplet.h",
"chars": 1349,
"preview": "#ifndef __TRIPLET_H\n#define __TRIPLET_H\n\n#include <cstddef>\n#include <utility>\n#include <functional>\n\ntemplate<class T, "
},
{
"path": "discretize/base/__init__.py",
"chars": 572,
"preview": "\"\"\"\n==================================\nBase Mesh (:mod:`discretize.base`)\n==================================\n.. currentm"
},
{
"path": "discretize/base/base_mesh.py",
"chars": 171299,
"preview": "\"\"\"Module for the base ``discretize`` mesh.\"\"\"\n\nimport numpy as np\nimport scipy.sparse as sp\nimport os\nimport json\nfrom "
},
{
"path": "discretize/base/base_regular_mesh.py",
"chars": 36403,
"preview": "\"\"\"Base classes for all regular shaped meshes supported in ``discretize``.\"\"\"\n\nimport numpy as np\nfrom discretize.utils "
},
{
"path": "discretize/base/base_tensor_mesh.py",
"chars": 39720,
"preview": "\"\"\"Base class for tensor-product style meshes.\"\"\"\n\nimport numpy as np\nimport scipy.sparse as sp\n\nfrom discretize.base.ba"
},
{
"path": "discretize/base/meson.build",
"chars": 177,
"preview": "\npython_sources = [\n '__init__.py',\n 'base_mesh.py',\n 'base_regular_mesh.py',\n 'base_tensor_mesh.py',\n]\n\npy.install_"
},
{
"path": "discretize/curvilinear_mesh.py",
"chars": 32684,
"preview": "\"\"\"Module containing the curvilinear mesh implementation.\"\"\"\n\nimport numpy as np\nimport scipy.sparse as sp\n\nfrom discret"
},
{
"path": "discretize/cylindrical_mesh.py",
"chars": 85759,
"preview": "\"\"\"Module containing the cylindrical mesh implementation.\"\"\"\n\nimport numpy as np\nimport scipy.sparse as sp\nfrom scipy.co"
},
{
"path": "discretize/meson.build",
"chars": 371,
"preview": "\npython_sources = [\n '__init__.py',\n 'curvilinear_mesh.py',\n 'cylindrical_mesh.py',\n 'tensor_cell.py',\n 'tensor_mes"
},
{
"path": "discretize/mixins/__init__.py",
"chars": 1542,
"preview": "\"\"\"\n==================================\nMixins (:mod:`discretize.mixins`)\n==================================\n.. currentmo"
},
{
"path": "discretize/mixins/mesh_io.py",
"chars": 22057,
"preview": "\"\"\"Module for reading and writing meshes to text files.\n\nThe text files representing meshes are often in the `UBC` forma"
},
{
"path": "discretize/mixins/meson.build",
"chars": 174,
"preview": "\npython_sources = [\n '__init__.py',\n 'mesh_io.py',\n 'mpl_mod.py',\n 'omf_mod.py',\n 'vtk_mod.py',\n]\n\npy.install_sourc"
},
{
"path": "discretize/mixins/mpl_mod.py",
"chars": 97343,
"preview": "\"\"\"Module for ``matplotlib`` interaction with ``discretize``.\"\"\"\n\nimport numpy as np\nimport warnings\nfrom discretize.uti"
},
{
"path": "discretize/mixins/omf_mod.py",
"chars": 11039,
"preview": "\"\"\"Module for ``omf`` interaction with ``discretize``.\"\"\"\n\nimport numpy as np\nimport discretize\n\n\ndef omf():\n \"\"\"Lazy"
},
{
"path": "discretize/mixins/vtk_mod.py",
"chars": 38684,
"preview": "\"\"\"Module for ``vtk`` interaction with ``discretize``.\n\nThis module provides a way for ``discretize`` meshes to be\nconve"
},
{
"path": "discretize/operators/__init__.py",
"chars": 591,
"preview": "\"\"\"\n================================================\nDiscrete Operators (:mod:`discretize.operators`)\n=================="
},
{
"path": "discretize/operators/differential_operators.py",
"chars": 142614,
"preview": "\"\"\"Differential operators for meshes.\"\"\"\n\nimport numpy as np\nfrom scipy import sparse as sp\nimport warnings\nfrom discret"
},
{
"path": "discretize/operators/inner_products.py",
"chars": 32325,
"preview": "\"\"\"Construct inner product operators for tensor like meshes.\"\"\"\n\nfrom scipy import sparse as sp\nfrom discretize.base imp"
},
{
"path": "discretize/operators/meson.build",
"chars": 167,
"preview": "\npython_sources = [\n '__init__.py',\n 'differential_operators.py',\n 'inner_products.py',\n]\n\npy.install_sources(\n pyth"
},
{
"path": "discretize/tensor_cell.py",
"chars": 13740,
"preview": "\"\"\"Cell class for TensorMesh.\"\"\"\n\nimport itertools\nimport numpy as np\n\n\nclass TensorCell:\n \"\"\"\n Representation of "
},
{
"path": "discretize/tensor_mesh.py",
"chars": 33292,
"preview": "\"\"\"Module housing the TensorMesh implementation.\"\"\"\n\nimport itertools\nimport numpy as np\n\nfrom discretize.base import Ba"
},
{
"path": "discretize/tests.py",
"chars": 36790,
"preview": "\"\"\"\n===========================================\nTesting Utilities (:mod:`discretize.tests`)\n============================"
},
{
"path": "discretize/tree_mesh.py",
"chars": 48059,
"preview": "\"\"\"Module containing the TreeMesh implementation.\"\"\"\n\nimport warnings\n\n# ___ ___ ___ ___ "
},
{
"path": "discretize/unstructured_mesh.py",
"chars": 49857,
"preview": "\"\"\"Module containing unstructured meshes for discretize.\"\"\"\n\nimport numpy as np\nimport scipy.sparse as sp\nfrom scipy.spa"
},
{
"path": "discretize/utils/__init__.py",
"chars": 3583,
"preview": "\"\"\"\n========================================================\nUtility Classes and Functions (:mod:`discretize.utils`)\n==="
},
{
"path": "discretize/utils/code_utils.py",
"chars": 11448,
"preview": "\"\"\"Utilities for common operations within code.\"\"\"\n\nimport numpy as np\nimport warnings\n\nSCALARTYPES = (complex, float, i"
},
{
"path": "discretize/utils/codeutils.py",
"chars": 254,
"preview": "from discretize.utils.code_utils import * # NOQA F401,F403\n\nraise ImportError(\n \"Importing from discretize.codeutils"
},
{
"path": "discretize/utils/coordinate_utils.py",
"chars": 10375,
"preview": "\"\"\"Simple utilities for coordinate transformations.\"\"\"\n\nimport numpy as np\nfrom discretize.utils.matrix_utils import mkv"
},
{
"path": "discretize/utils/coordutils.py",
"chars": 261,
"preview": "from discretize.utils.coordinate_utils import * # NOQA F401,F403\n\nraise ImportError(\n \"Importing from discretize.coo"
},
{
"path": "discretize/utils/curvilinear_utils.py",
"chars": 18105,
"preview": "\"\"\"Functions for working with curvilinear meshes.\"\"\"\n\nimport numpy as np\nfrom discretize.utils.matrix_utils import mkvc,"
},
{
"path": "discretize/utils/curvutils.py",
"chars": 261,
"preview": "from discretize.utils.curvilinear_utils import * # NOQA F401,F403\n\nraise ImportError(\n \"Importing from discretize.cu"
},
{
"path": "discretize/utils/interpolation_utils.py",
"chars": 10929,
"preview": "\"\"\"Utilities for creating averaging operators.\"\"\"\n\nimport numpy as np\nimport scipy.sparse as sp\nfrom discretize.utils.ma"
},
{
"path": "discretize/utils/interputils.py",
"chars": 265,
"preview": "from discretize.utils.interpolation_utils import * # NOQA F401,F403\n\nraise ImportError(\n \"Importing from discretize."
},
{
"path": "discretize/utils/io_utils.py",
"chars": 3881,
"preview": "\"\"\"Simple input/output routines.\"\"\"\n\nfrom urllib.request import urlretrieve\nimport os\nimport importlib\nimport json\n\n\ndef"
},
{
"path": "discretize/utils/matrix_utils.py",
"chars": 58693,
"preview": "\"\"\"Useful functions for working with vectors and matrices.\"\"\"\n\nimport numpy as np\nimport scipy.sparse as sp\nfrom discret"
},
{
"path": "discretize/utils/matutils.py",
"chars": 255,
"preview": "from discretize.utils.matrix_utils import * # NOQA F401,F403\n\nraise ImportError(\n \"Importing from discretize.matutil"
},
{
"path": "discretize/utils/mesh_utils.py",
"chars": 43869,
"preview": "\"\"\"Useful tools for working with meshes.\"\"\"\n\nimport numpy as np\nimport scipy.ndimage as ndi\nimport scipy.sparse as sp\n\nf"
},
{
"path": "discretize/utils/meshutils.py",
"chars": 254,
"preview": "from discretize.utils.mesh_utils import * # NOQA F401,F403\n\nraise ImportError(\n \"Importing from discretize.meshutils"
},
{
"path": "discretize/utils/meson.build",
"chars": 374,
"preview": "\npython_sources = [\n '__init__.py',\n 'code_utils.py',\n 'coordinate_utils.py',\n 'curvilinear_utils.py',\n 'interpolat"
},
{
"path": "docs/Makefile",
"chars": 2657,
"preview": "# Makefile for Sphinx documentation\n#\n\n# You can set these variables from the command line.\nSPHINXOPTS = -j auto\nSPHI"
},
{
"path": "docs/_static/css/custom.css",
"chars": 1589,
"preview": "@import url(https://fonts.googleapis.com/css?family=Raleway);\n\n.bd-header .navbar-header-items__center {\n margin: aut"
},
{
"path": "docs/_static/versions.json",
"chars": 921,
"preview": "[\n { \"name\": \"main\",\n \"version\": \"dev\",\n \"url\": \"https://discretize.simpeg.xyz/en/main/\"\n },\n {"
},
{
"path": "docs/_templates/autosummary/attribute.rst",
"chars": 115,
"preview": ":orphan:\n\n{{ fullname | escape | underline}}\n\n.. currentmodule:: {{ module }}\n\n.. auto{{ objtype }}:: {{ objname }}"
},
{
"path": "docs/_templates/autosummary/base.rst",
"chars": 158,
"preview": "{% if objtype == 'property' %}\n:orphan:\n{% endif %}\n\n{{ fullname | escape | underline}}\n\n.. currentmodule:: {{ module }}"
},
{
"path": "docs/_templates/autosummary/class.rst",
"chars": 1306,
"preview": "{{ fullname }}\n{{ underline }}\n\n.. currentmodule:: {{ module }}\n\n.. inheritance-diagram:: {{ objname }}\n :parts: 1\n\n."
},
{
"path": "docs/_templates/autosummary/function.rst",
"chars": 224,
"preview": "{{ fullname | escape | underline }}\n\n.. currentmodule:: {{ module }}\n\n.. autofunction:: {{ objname }}\n\n.. minigallery:: "
},
{
"path": "docs/_templates/autosummary/method.rst",
"chars": 115,
"preview": ":orphan:\n\n{{ fullname | escape | underline}}\n\n.. currentmodule:: {{ module }}\n\n.. auto{{ objtype }}:: {{ objname }}"
},
{
"path": "docs/api/discretize.base.rst",
"chars": 32,
"preview": ".. automodule:: discretize.base\n"
},
{
"path": "docs/api/discretize.mixins.rst",
"chars": 34,
"preview": ".. automodule:: discretize.mixins\n"
},
{
"path": "docs/api/discretize.operators.rst",
"chars": 37,
"preview": ".. automodule:: discretize.operators\n"
},
{
"path": "docs/api/discretize.rst",
"chars": 27,
"preview": ".. automodule:: discretize\n"
},
{
"path": "docs/api/discretize.tests.rst",
"chars": 33,
"preview": ".. automodule:: discretize.tests\n"
},
{
"path": "docs/api/discretize.utils.rst",
"chars": 33,
"preview": ".. automodule:: discretize.utils\n"
},
{
"path": "docs/api/index.rst",
"chars": 846,
"preview": ".. _api:\n\n=============\nAPI Reference\n=============\n\nMeshes\n======\n\nMeshes supported by the ``discretize`` package.\nThe "
},
{
"path": "docs/conf.py",
"chars": 15961,
"preview": "# -*- coding: utf-8 -*-\n#\n# discretize documentation build configuration file, created by\n# sphinx-quickstart on Fri Aug"
},
{
"path": "docs/content/additional_resources.rst",
"chars": 1383,
"preview": ".. _additional_resources:\n\nAdditional Resources\n====================\n\nAn enormous amount of information (including tutor"
},
{
"path": "docs/content/big_picture.rst",
"chars": 2227,
"preview": "Why discretize?\n===============\n\nInverse problems are common across the geosciences: imaging in geophysics,\nhistory matc"
},
{
"path": "docs/content/finite_volume.rst",
"chars": 794,
"preview": ".. _api_FiniteVolume:\n\nFinite Volume\n*************\n\nAny numerical implementation requires the discretization of continuo"
},
{
"path": "docs/content/getting_started.rst",
"chars": 228,
"preview": ".. _getting_started:\n\n===============\nGetting Started\n===============\n\nHere you'll find instructions on getting up and r"
},
{
"path": "docs/content/inner_products.rst",
"chars": 10172,
"preview": "Inner Products\n**************\n\nBy using the weak formulation of many of the PDEs in geophysical applications,\nwe can rap"
},
{
"path": "docs/content/installing.rst",
"chars": 4462,
"preview": ".. _api_installing:\n\nInstalling\n**********\n\nWhich Python?\n=============\n\nCurrently, ``discretize`` is tested on python 3"
},
{
"path": "docs/content/theory.rst",
"chars": 191,
"preview": ".. _theory:\n\n======\nTheory\n======\nThis section is a resource for the fundamental finite volume theory used behind\n`discr"
},
{
"path": "docs/content/user_guide.rst",
"chars": 486,
"preview": ".. _user_guide:\n\n==========\nUser Guide\n==========\nWe've included some tutorials and gallery examples that will walk you "
},
{
"path": "docs/index.rst",
"chars": 191,
"preview": ".. include:: ../README.rst\n\n.. toctree::\n :maxdepth: 3\n :hidden:\n :titlesonly:\n\n content/getting_started\n "
},
{
"path": "docs/make.bat",
"chars": 5096,
"preview": "@ECHO OFF\n\nREM Command file for Sphinx documentation\n\nif \"%SPHINXBUILD%\" == \"\" (\n\tset SPHINXBUILD=sphinx-build\n)\nset BUI"
},
{
"path": "docs/release/0.10.0-notes.rst",
"chars": 3336,
"preview": ".. currentmodule:: discretize\n\n.. _0.10.0_notes:\n\n===================================\n``discretize`` 0.10.0 Release Note"
},
{
"path": "docs/release/0.11.0-notes.rst",
"chars": 4454,
"preview": ".. currentmodule:: discretize\n\n.. _0.11.0_notes:\n\n===================================\n``discretize`` 0.11.0 Release Note"
},
{
"path": "docs/release/0.11.1-notes.rst",
"chars": 1247,
"preview": ".. currentmodule:: discretize\n\n.. _0.11.1_notes:\n\n===================================\n``discretize`` 0.11.1 Release Note"
},
{
"path": "docs/release/0.11.2-notes.rst",
"chars": 1488,
"preview": ".. currentmodule:: discretize\n\n.. _0.11.2_notes:\n\n===================================\n``discretize`` 0.11.2 Release Note"
},
{
"path": "docs/release/0.11.3-notes.rst",
"chars": 1090,
"preview": ".. currentmodule:: discretize\n\n.. _0.11.3_notes:\n\n===================================\n``discretize`` 0.11.3 Release Note"
},
{
"path": "docs/release/0.12.0-notes.rst",
"chars": 2053,
"preview": ".. currentmodule:: discretize\n\n.. _0.12.0_notes:\n\n===================================\n``discretize`` 0.12.0 Release Note"
},
{
"path": "docs/release/0.4.12-notes.rst",
"chars": 2270,
"preview": ".. currentmodule:: discretize\n\n.. _0.4.12_notes:\n\n===================================\n``discretize`` 0.4.12 Release Note"
},
{
"path": "docs/release/0.4.13-notes.rst",
"chars": 1191,
"preview": ".. currentmodule:: discretize\n\n.. _0.4.13_notes:\n\n===================================\n``discretize`` 0.4.13 Release Note"
},
{
"path": "docs/release/0.4.14-notes.rst",
"chars": 877,
"preview": ".. currentmodule:: discretize\n\n.. _0.4.14_notes:\n\n===================================\n``discretize`` 0.4.14 Release Note"
},
{
"path": "docs/release/0.4.15-notes.rst",
"chars": 411,
"preview": ".. currentmodule:: discretize\n\n.. _0.4.15_notes:\n\n===================================\n``discretize`` 0.4.15 Release Note"
},
{
"path": "docs/release/0.5.0-notes.rst",
"chars": 1271,
"preview": ".. currentmodule:: discretize\n\n.. _0.5.0_notes:\n\n===================================\n``discretize`` 0.5.0 Release Notes\n"
},
{
"path": "docs/release/0.5.1-notes.rst",
"chars": 645,
"preview": ".. currentmodule:: discretize\n\n.. _0.5.1_notes:\n\n===================================\n``discretize`` 0.5.1 Release Notes\n"
},
{
"path": "docs/release/0.6.0-notes.rst",
"chars": 8833,
"preview": ".. currentmodule:: discretize\n\n.. _0.6.0_notes:\n\n===================================\n``discretize`` 0.6.0 Release Notes\n"
},
{
"path": "docs/release/0.6.1-notes.rst",
"chars": 1067,
"preview": ".. currentmodule:: discretize\n\n.. _0.6.1_notes:\n\n===================================\n``discretize`` 0.6.1 Release Notes\n"
},
{
"path": "docs/release/0.6.2-notes.rst",
"chars": 585,
"preview": ".. currentmodule:: discretize\n\n.. _0.6.2_notes:\n\n===================================\n``discretize`` 0.6.2 Release Notes\n"
},
{
"path": "docs/release/0.6.3-notes.rst",
"chars": 1486,
"preview": ".. currentmodule:: discretize\n\n.. _0.6.3_notes:\n\n===================================\n``discretize`` 0.6.3 Release Notes\n"
},
{
"path": "docs/release/0.7.0-notes.rst",
"chars": 4086,
"preview": ".. currentmodule:: discretize\n\n.. _0.7.0_notes:\n\n===================================\n``discretize`` 0.7.0 Release Notes\n"
},
{
"path": "docs/release/0.7.1-notes.rst",
"chars": 1546,
"preview": ".. currentmodule:: discretize\n\n.. _0.7.1_notes:\n\n===================================\n``discretize`` 0.7.1 Release Notes\n"
},
{
"path": "docs/release/0.7.2-notes.rst",
"chars": 1106,
"preview": ".. currentmodule:: discretize\n\n.. _0.7.2_notes:\n\n===================================\n``discretize`` 0.7.2 Release Notes\n"
},
{
"path": "docs/release/0.7.3-notes.rst",
"chars": 952,
"preview": ".. currentmodule:: discretize\n\n.. _0.7.3_notes:\n\n===================================\n``discretize`` 0.7.3 Release Notes\n"
},
{
"path": "docs/release/0.7.4-notes.rst",
"chars": 766,
"preview": ".. currentmodule:: discretize\n\n.. _0.7.4_notes:\n\n===================================\n``discretize`` 0.7.4 Release Notes\n"
},
{
"path": "docs/release/0.8.0-notes.rst",
"chars": 2311,
"preview": ".. currentmodule:: discretize\n\n.. _0.8.0_notes:\n\n===================================\n``discretize`` 0.8.0 Release Notes\n"
},
{
"path": "docs/release/0.8.1-notes.rst",
"chars": 2154,
"preview": ".. currentmodule:: discretize\n\n.. _0.8.1_notes:\n\n===================================\n``discretize`` 0.8.1 Release Notes\n"
},
{
"path": "docs/release/0.8.2-notes.rst",
"chars": 473,
"preview": ".. currentmodule:: discretize\n\n.. _0.8.2_notes:\n\n===================================\n``discretize`` 0.8.2 Release Notes\n"
},
{
"path": "docs/release/0.8.3-notes.rst",
"chars": 3259,
"preview": ".. currentmodule:: discretize\n\n.. _0.8.3_notes:\n\n===================================\n``discretize`` 0.8.3 Release Notes\n"
},
{
"path": "docs/release/0.9.0-notes.rst",
"chars": 3200,
"preview": ".. currentmodule:: discretize\n\n.. _0.9.0_notes:\n\n===================================\n``discretize`` 0.9.0 Release Notes\n"
},
{
"path": "docs/release/index.rst",
"chars": 699,
"preview": "Release Notes\n=============\n\n.. toctree::\n :maxdepth: 2\n\n 0.12.0 <0.12.0-notes>\n 0.11.3 <0.11.3-notes>\n 0.11.2"
},
{
"path": "examples/README.txt",
"chars": 41,
"preview": ".. _sphx_glr_examples:\n\nExamples\n********"
},
{
"path": "examples/plot_cahn_hilliard.py",
"chars": 4055,
"preview": "r\"\"\"\nOperators: Cahn Hilliard\n========================\n\nThis example is based on the example in the FiPy_ library.\nPleas"
},
{
"path": "examples/plot_cyl_mirror.py",
"chars": 1578,
"preview": "\"\"\"\nPlot Mirrored Cylindrically Symmetric Model\n===========================================\n\nHere, we demonstrate plotti"
},
{
"path": "examples/plot_dc_resistivity.py",
"chars": 1814,
"preview": "\"\"\"\nBasic Forward 2D DC Resistivity\n===============================\n\n2D DC forward modeling example with Tensor and Curv"
},
{
"path": "examples/plot_image.py",
"chars": 1345,
"preview": "\"\"\"\nBasic: PlotImage\n================\n\nYou can use M.PlotImage to plot images on all of the Meshes.\n\"\"\"\n\nimport discreti"
},
{
"path": "examples/plot_pyvista_laguna.py",
"chars": 5005,
"preview": "\"\"\"\n.. _pyvista_demo_ref:\n\n3D Visualization with PyVista\n=============================\n\nThe example demonstrates the how"
},
{
"path": "examples/plot_quadtree_divergence.py",
"chars": 1807,
"preview": "\"\"\"\nQuadTree: FaceDiv\n=================\n\nFor a tree mesh, there needs to be special attention taken for the hanging\nface"
},
{
"path": "examples/plot_quadtree_hanging.py",
"chars": 975,
"preview": "\"\"\"\nQuadTree: Hanging Nodes\n=======================\n\nYou can give the refine method a function, which is evaluated on ev"
},
{
"path": "examples/plot_slicer_demo.py",
"chars": 6837,
"preview": "\"\"\"\nSlicer demo\n===========\n\nThe example demonstrates the `plot_3d_slicer`\n\n- contributed by `@prisae <https://github.co"
},
{
"path": "examples/plot_streamThickness.py",
"chars": 1961,
"preview": "\"\"\"\nPlotting: Streamline thickness\n==============================\n\nA simple example to vary streamline thickness based o"
},
{
"path": "meson.build",
"chars": 1386,
"preview": "project(\n 'discretize',\n 'c', 'cpp', 'cython',\n # Note that the git commit hash cannot be added dynamically here\n # "
},
{
"path": "meson.options",
"chars": 56,
"preview": "option('cy_line_trace', type : 'boolean', value : false)"
},
{
"path": "pyproject.toml",
"chars": 5695,
"preview": "\n[build-system]\nbuild-backend = 'mesonpy'\nrequires = [\n \"meson-python>=0.15.0\",\n \"Cython>=3.1.0\",\n \"setuptools_"
},
{
"path": "tests/__init__.py",
"chars": 400,
"preview": "if __name__ == \"__main__\":\n import glob\n import unittest\n\n test_file_strings = glob.glob(\"test_*.py\")\n modul"
},
{
"path": "tests/base/__init__.py",
"chars": 400,
"preview": "if __name__ == \"__main__\":\n import glob\n import unittest\n\n test_file_strings = glob.glob(\"test_*.py\")\n modul"
},
{
"path": "tests/base/test_basemesh.py",
"chars": 10484,
"preview": "import unittest\nfrom discretize.base import BaseRectangularMesh, BaseMesh\nimport numpy as np\nimport inspect\n\n\nclass Test"
},
{
"path": "tests/base/test_coordutils.py",
"chars": 2399,
"preview": "import unittest\nimport numpy as np\nfrom discretize import utils\n\ntol = 1e-15\n\nrng = np.random.default_rng(523)\n\n\nclass c"
},
{
"path": "tests/base/test_curvilinear.py",
"chars": 8471,
"preview": "import numpy as np\nimport unittest\nfrom discretize import TensorMesh, CurvilinearMesh\nfrom discretize.utils import ndgri"
},
{
"path": "tests/base/test_curvilinear_vtk.py",
"chars": 1822,
"preview": "import numpy as np\nimport unittest\nimport os\nimport discretize\n\ntry:\n import vtk.util.numpy_support as nps\nexcept Imp"
},
{
"path": "tests/base/test_interpolation.py",
"chars": 12067,
"preview": "import numpy as np\nimport unittest\n\nimport discretize\n\nMESHTYPES = [\"uniformTensorMesh\", \"randomTensorMesh\"]\nTOLERANCES "
},
{
"path": "tests/base/test_operators.py",
"chars": 26395,
"preview": "import numpy as np\nimport unittest\nimport discretize\n\n# Tolerance\nTOL = 1e-14\n\ngen = np.random.default_rng(1)\n\nMESHTYPES"
},
{
"path": "tests/base/test_properties.py",
"chars": 5329,
"preview": "import unittest\nimport os\nimport numpy as np\nimport discretize\n\n\ndef compare_meshes(test, mesh0, mesh1):\n # check som"
},
{
"path": "tests/base/test_slicer.py",
"chars": 1640,
"preview": "import numpy as np\nimport pytest\n\ntry:\n from matplotlib.colors import Normalize\nexcept ImportError:\n pytest.skip(\""
},
{
"path": "tests/base/test_tensor.py",
"chars": 11272,
"preview": "import pytest\nimport numpy as np\nimport numpy.testing as npt\nimport unittest\nimport discretize\nfrom scipy.sparse.linalg "
},
{
"path": "tests/base/test_tensor_cell.py",
"chars": 22980,
"preview": "\"\"\"Test TensorCell.\"\"\"\n\nimport pytest\nimport numpy as np\n\nfrom discretize import TensorCell, TensorMesh\nfrom discretize."
},
{
"path": "tests/base/test_tensor_innerproduct.py",
"chars": 27773,
"preview": "import numpy as np\nimport unittest\nimport discretize\nfrom discretize import TensorMesh\nfrom discretize.utils import sdin"
},
{
"path": "tests/base/test_tensor_innerproduct_derivs.py",
"chars": 20525,
"preview": "import numpy as np\nimport unittest\nimport discretize\nfrom discretize import TensorMesh\n\nrng = np.random.default_rng(542)"
},
{
"path": "tests/base/test_tensor_io.py",
"chars": 1612,
"preview": "import numpy as np\nimport discretize\nimport pytest\n\ntry:\n import vtk # NOQA F401\n\n has_vtk = True\nexcept ImportEr"
},
{
"path": "tests/base/test_tensor_omf.py",
"chars": 4021,
"preview": "import numpy as np\nimport unittest\nimport discretize\n\ntry:\n import omf\nexcept ImportError:\n has_omf = False\nelse:\n"
},
{
"path": "tests/base/test_tensor_vtk.py",
"chars": 1428,
"preview": "import numpy as np\nimport unittest\nimport discretize\n\ntry:\n import vtk.util.numpy_support as nps\nexcept ImportError:\n"
},
{
"path": "tests/base/test_tests.py",
"chars": 5771,
"preview": "import sys\nimport pytest\nimport discretize\nimport subprocess\nimport numpy as np\nimport scipy.sparse as sp\nfrom discretiz"
},
{
"path": "tests/base/test_utils.py",
"chars": 21097,
"preview": "import unittest\nimport numpy as np\nimport scipy.sparse as sp\nfrom discretize.utils import (\n sdiag,\n sub2ind,\n "
},
{
"path": "tests/base/test_view.py",
"chars": 1760,
"preview": "import unittest\nimport numpy as np\nimport pytest\n\ntry:\n import matplotlib.pyplot as plt\nexcept ImportError:\n pytes"
},
{
"path": "tests/base/test_volume_avg.py",
"chars": 4284,
"preview": "import numpy as np\nimport pytest\nimport discretize\nfrom discretize.utils import volume_average\nfrom numpy.testing import"
},
{
"path": "tests/boundaries/test_boundary_integrals.py",
"chars": 8593,
"preview": "import numpy as np\nimport scipy.sparse as sp\nimport discretize\nfrom discretize.utils import cart2cyl, cyl2cart\n\n\ndef u(*"
},
{
"path": "tests/boundaries/test_boundary_maxwell.py",
"chars": 4128,
"preview": "import numpy as np\nimport discretize\nfrom discretize import utils\nfrom scipy.sparse.linalg import spsolve\n\n\nclass TestFz"
},
{
"path": "tests/boundaries/test_boundary_poisson.py",
"chars": 23413,
"preview": "import numpy as np\nimport scipy.sparse as sp\nfrom scipy.sparse import linalg\nimport unittest\nimport discretize\nfrom disc"
},
{
"path": "tests/boundaries/test_errors.py",
"chars": 5165,
"preview": "import unittest\nimport numpy as np\nimport discretize\n\n\nrng = np.random.default_rng(53679)\n\n\nclass RobinOperatorTest(unit"
},
{
"path": "tests/boundaries/test_tensor_boundary.py",
"chars": 16830,
"preview": "import numpy as np\nimport unittest\nimport discretize\nfrom scipy.sparse.linalg import spsolve\n\nMESHTYPES = [\"uniformTenso"
},
{
"path": "tests/boundaries/test_tensor_boundary_poisson.py",
"chars": 17547,
"preview": "import numpy as np\nimport scipy.sparse as sp\nimport unittest\nimport discretize\nfrom discretize import utils\nfrom scipy.s"
},
{
"path": "tests/cyl/__init__.py",
"chars": 400,
"preview": "if __name__ == \"__main__\":\n import glob\n import unittest\n\n test_file_strings = glob.glob(\"test_*.py\")\n modul"
},
{
"path": "tests/cyl/test_cyl.py",
"chars": 22364,
"preview": "import unittest\nimport numpy as np\nimport pytest\n\nimport discretize\nfrom discretize import tests, utils\n\nrng = np.random"
},
{
"path": "tests/cyl/test_cyl3D.py",
"chars": 12137,
"preview": "import unittest\nimport numpy as np\n\nimport discretize\nfrom discretize import utils\n\nTOL = 1e-1\n\n\nclass TestCyl3DGeometri"
},
{
"path": "tests/cyl/test_cylOperators.py",
"chars": 6659,
"preview": "import unittest\nimport numpy as np\nimport sympy\nfrom sympy.abc import r, t, z\n\nimport discretize\nfrom discretize import "
},
{
"path": "tests/cyl/test_cyl_counting.py",
"chars": 18378,
"preview": "import numpy as np\nimport discretize\n\n\ndef test_pizza_slice_counting():\n # pizza slice includes r=0, but doesn't wrap"
},
{
"path": "tests/cyl/test_cyl_innerproducts.py",
"chars": 30746,
"preview": "import discretize\nfrom discretize import tests\nimport numpy as np\nimport sympy\nfrom sympy.abc import r, t, z\nimport unit"
},
{
"path": "tests/cyl/test_cyl_io.py",
"chars": 1981,
"preview": "import discretize\nimport pytest\nimport os\nimport numpy as np\n\ntry:\n import matplotlib.pyplot as plt\nexcept ImportErro"
},
{
"path": "tests/cyl/test_cyl_operators.py",
"chars": 16999,
"preview": "import numpy as np\nimport discretize\nimport discretize.tests as tests\nimport sympy as sp\nfrom sympy.vector import CoordS"
},
{
"path": "tests/simplex/__init__.py",
"chars": 400,
"preview": "if __name__ == \"__main__\":\n import glob\n import unittest\n\n test_file_strings = glob.glob(\"test_*.py\")\n modul"
},
{
"path": "tests/simplex/test_inner_products.py",
"chars": 18970,
"preview": "import numpy as np\nimport unittest\nimport discretize\nimport scipy.sparse as sp\nfrom discretize.utils import example_simp"
},
{
"path": "tests/simplex/test_interpolation.py",
"chars": 15078,
"preview": "import numpy as np\nimport discretize\nfrom discretize.utils import example_simplex_mesh\n\n\nclass TestInterpolation2d(discr"
},
{
"path": "tests/simplex/test_operators.py",
"chars": 6433,
"preview": "import numpy as np\nimport pytest\n\nimport discretize\nfrom discretize import SimplexMesh\nfrom discretize.utils import exam"
},
{
"path": "tests/simplex/test_utils.py",
"chars": 6036,
"preview": "import unittest\nimport pytest\nimport numpy as np\nimport discretize\nfrom discretize.utils import example_simplex_mesh\nimp"
},
{
"path": "tests/tree/__init__.py",
"chars": 400,
"preview": "if __name__ == \"__main__\":\n import glob\n import unittest\n\n test_file_strings = glob.glob(\"test_*.py\")\n modul"
},
{
"path": "tests/tree/test_intersections.py",
"chars": 6401,
"preview": "import discretize\nimport numpy as np\nimport pytest\nfrom discretize.tests import assert_cell_intersects_geometric\n\npytest"
},
{
"path": "tests/tree/test_refine.py",
"chars": 17718,
"preview": "import re\nimport discretize\nimport numpy as np\nimport numpy.testing as npt\nimport pytest\nfrom discretize.tests import as"
},
{
"path": "tests/tree/test_safeguards.py",
"chars": 3880,
"preview": "\"\"\"\nTest safeguards against accessing certain properties on non-finalized TreeMesh.\n\"\"\"\n\nimport re\nimport pytest\n\nfrom d"
},
{
"path": "tests/tree/test_tree.py",
"chars": 19263,
"preview": "import numpy as np\nimport unittest\nimport pytest\nimport discretize\n\nTOL = 1e-8\n\nrng = np.random.default_rng(6234)\n\n\nclas"
},
{
"path": "tests/tree/test_tree_balancing.py",
"chars": 5646,
"preview": "import discretize\nimport numpy as np\n\n\ndef check_for_diag_unbalance(mesh):\n avg = mesh.average_node_to_cell.T.tocsr()"
},
{
"path": "tests/tree/test_tree_innerproduct_derivs.py",
"chars": 11209,
"preview": "import numpy as np\nimport unittest\nimport discretize\n\nrng = np.random.default_rng(678423)\n\n\nclass TestInnerProductsDeriv"
},
{
"path": "tests/tree/test_tree_interpolation.py",
"chars": 5252,
"preview": "import numpy as np\nimport discretize\n\nimport pytest\n\nMESHTYPES = [\"uniformTree\"] # ['randomTree', 'uniformTree']\ncall2 "
},
{
"path": "tests/tree/test_tree_io.py",
"chars": 2602,
"preview": "import warnings\nimport numpy as np\nimport discretize\nimport pickle\nimport json\nimport pytest\n\ntry:\n import vtk # NOQ"
},
{
"path": "tests/tree/test_tree_operators.py",
"chars": 38825,
"preview": "import numpy as np\nimport discretize\n\nMESHTYPES = [\"uniformTree\", \"randomTree\"]\n# MESHTYPES = ['randomTree']\ncall2 = lam"
},
{
"path": "tests/tree/test_tree_plotting.py",
"chars": 3468,
"preview": "import pytest\n\ntry:\n import matplotlib\n import matplotlib.pyplot as plt\n\n matplotlib.use(\"Agg\")\nexcept ImportEr"
},
{
"path": "tests/tree/test_tree_utils.py",
"chars": 4436,
"preview": "import numpy as np\nimport unittest\nfrom discretize.utils import mesh_builder_xyz, refine_tree_xyz\n\nTOL = 1e-8\n\n\nclass Te"
},
{
"path": "tests/tree/test_tree_vtk.py",
"chars": 1584,
"preview": "import numpy as np\nimport unittest\nimport discretize\n\ntry:\n import vtk.util.numpy_support as nps\nexcept ImportError:\n"
},
{
"path": "tutorials/inner_products/1_basic.py",
"chars": 8191,
"preview": "r\"\"\"\nBasic Inner Products\n====================\n\nInner products between two scalar or vector quantities represents the mo"
},
{
"path": "tutorials/inner_products/2_physical_properties.py",
"chars": 12145,
"preview": "r\"\"\"\nConstitutive Relations\n======================\n\nWhen solving PDEs using the finite volume approach, inner products m"
},
{
"path": "tutorials/inner_products/3_calculus.py",
"chars": 9354,
"preview": "r\"\"\"\nDifferential Operators\n======================\n\nWhen solving PDEs using the finite volume approach, inner products m"
}
]
// ... and 14 more files (download for full content)
About this extraction
This page contains the full source code of the simpeg/discretize GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 214 files (2.1 MB), approximately 572.0k tokens, and a symbol index with 2009 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.