TTFEMesh
TTFEMesh is a Python library for generating tensor train representations of finite element meshes. It provides tools for creating domains, generating meshes, and computing tensorized Jacobians, Dirichlet masks, and concatenation maps.
This provides the backbone for solving partial differential equations using TT decompositions. The package is designed to be flexible and extensible, allowing users to create their own finite element meshes and build their own solvers.
The package is built on top of the torchtt package, which provides a framework
for handling TT decompositions, but this might change in the future.
This package is currently in a prototype stage, and the API is subject to change.
For more technical details on how to manipulate finite element meshes in the tensor train format, please refer to the original paper and the extensions in this work.
Installation
Platform Support
TTFEMesh is currently only supported on Linux systems due to dependencies on the torchtt package. For other platforms (macOS, Windows), we recommend using Docker.
Linux Installation
Install system dependencies:
sudo apt-get update
sudo apt-get install -y libblas-dev liblapack-dev
Install the package:
pip install ttfemesh
Requirements
Python >= 3.10, < 3.13
Linux operating system (or Docker)
BLAS and LAPACK libraries (system dependencies)
torchtt (for tensor train operations)
Other dependencies listed in
requirements.txt
Documentation
User Guide
Core Modules
API Reference
Quick Start
Here’s a quick example of how to use TTFEMesh:
from ttfemesh.domain import RectangleFactory, CurveConnection2D, DirichletBoundary2D, Domain2D
from ttfemesh.quadrature import GaussLegendre2D
from ttfemesh.mesh import DomainBilinearMesh2D
# Create a domain with two rectangles
lower_left = (0, 0)
upper_right = (2, 1)
rectangle1 = RectangleFactory.create(lower_left, upper_right)
lower_left = (2, 0)
upper_right = (3, 1)
rectangle2 = RectangleFactory.create(lower_left, upper_right)
# Connect the rectangles
domain_idxs = [0, 1]
curve_idxs = [1, 3]
edge = CurveConnection2D(domain_idxs, curve_idxs)
# Set boundary conditions
bc = DirichletBoundary2D([(0, 3), (1, 1)])
# Create the domain
domain = Domain2D([rectangle1, rectangle2], [edge], bc)
# Generate a mesh
order = 1
qrule = GaussLegendre2D(order)
mesh_size_exponent = 3
mesh = DomainBilinearMesh2D(domain, qrule, mesh_size_exponent)
# Get tensorized Jacobians
subdmesh = mesh.get_subdomain_mesh(0)
jac_tts = subdmesh.get_jacobian_tensor_trains()
jac_dets = subdmesh.get_jacobian_det_tensor_trains()
jac_invdets = subdmesh.get_jacobian_invdet_tensor_trains()
# Get element to global index map
element2global_map = mesh.get_element2global_index_map()
# Get Dirichlet masks
masks = mesh.get_dirichlet_masks()
# Get concatenation maps
concat_maps = mesh.get_concatenation_maps()
For more detailed examples and tutorials, check out our Quickstart Guide.
Contributing
We welcome contributions! Please visit our GitHub repository to:
Report bugs
Suggest features
Submit pull requests
License
TTFEMesh is licensed under the MIT License - see the LICENSE file for details.