项目作者: qTipTip

项目描述 :
Truncated Hierarchical B-Splines in Python
高级语言: Python
项目地址: git://github.com/qTipTip/THBSplines.git
创建时间: 2018-11-08T10:48:15Z
项目社区:https://github.com/qTipTip/THBSplines

开源协议:

下载


THBSplines

Truncated Hierarchical B-Splines in Python

This repository contains a dimension-independent Python-implementation of truncated hierarchical B-splines, and methods for the assembly of stiffness
and mass matrices. The code is currently in a fairly undocumented state, and may contain bugs - so use at your own discretion.

The implementation is based on the article Algorithms for the implementation of adaptive isogeometric methods using hierarchical B-splines,
and is heavily influenced by the GeoPDEs Matlab/Octave package for isogeometric analysis developed by the authors.

Example - computing the mass and stiffness matrix

The computation of finite element matrices is fairly simple. Initialize the hierarchical space. Refine the space by choosing specific elements, or a rectangular region of refinement, and finally, assemble the matrices.

  1. import THBSplines as thb
  2. import matplotlib.pyplot as plt
  3. # Initialize a biquadraic space of Truncated Hierarchical B-Splines
  4. knots = [
  5. [0, 0, 1/3, 2/3, 1, 1],
  6. [0, 0, 1/3, 2/3, 1, 1]
  7. ]
  8. degrees = [2, 2]
  9. dimension = 2
  10. T = thb.HierarchicalSpace(knots, degrees, dimension)
  11. # Select cells to refine at each level, either by explicitly marking the elements, or by choosing a rectangular region.
  12. cells_to_refine = {}
  13. cells_to_refine[0] = [0, 1, 2, 3, 4, 5, 6]
  14. T = thb.refine(T, cells_to_refine)
  15. rect = np.array([[0, 1 / 3], [0, 2 / 3]])
  16. cells_to_refine[1] = T.refine_in_rectangle(rect, level = 1)
  17. T = thb.refine(T, cells_to_refine)
  18. T.mesh.plot_cells()

  1. # If no integration order is specified, exact gauss quadrature suitable for the given basis is used.
  2. mass_matrix = thb.hierarchical_mass_matrix(T)
  3. stiffness_matrix = thb.hierarchical_stiffness_matrix(T)
  4. plt.spy(mass_matrix, markersize=1)
  5. plt.show()

Installation

Simply clone or download the repository and execute

  1. pip install .

from the root directory. Verify the installation by calling

  1. pytest

from the root directory.