lsdo-function-spaces 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lsdo_function_spaces-1.0.0/LICENSE.txt +165 -0
- lsdo_function_spaces-1.0.0/MANIFEST.in +10 -0
- lsdo_function_spaces-1.0.0/PKG-INFO +189 -0
- lsdo_function_spaces-1.0.0/README.md +147 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/__init__.py +64 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/__init__.py +0 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/function.py +1322 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/function_set.py +1081 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/function_set_space.py +379 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/function_space.py +482 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/operations/__init__.py +0 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/operations/basic_ops.py +85 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/operations/operations.py +5 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/optimization.py +183 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/__init__.py +0 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/b_spline_space.py +418 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/conditional_space.py +65 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/constant_space.py +57 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/idw_space.py +271 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/non_cython_bsplines/__init__.py +0 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/non_cython_bsplines/b_spline_csdl_custom_ops.py +420 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/non_cython_bsplines/b_spline_patch_projection.py +1022 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/non_cython_bsplines/b_spline_patch_projection_non_differentiable.py +186 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/non_cython_bsplines/b_spline_patch_projection_optimized.py +594 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/non_cython_bsplines/b_spline_space_new.py +6 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/non_cython_bsplines/compute_basis_matrix_jax.py +172 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/non_cython_bsplines/compute_basis_matrix_jax_factory.py +382 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/non_cython_bsplines/compute_basis_matrix_jax_stencil.py +451 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/non_cython_bsplines/compute_basis_matrix_numpy.py +249 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/non_cython_bsplines/compute_basis_matrix_numpy_factory.py +391 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/operation_space.py +64 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/polynomial_space.py +79 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/rbf_space.py +136 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/core/spaces/tri_space.py +256 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/utils/__init__.py +0 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/utils/file_io.py +484 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/utils/internal_utilities.py +11 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/utils/plotting_functions.py +357 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces/utils/utility_functions.py +148 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces.egg-info/PKG-INFO +189 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces.egg-info/SOURCES.txt +94 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces.egg-info/dependency_links.txt +1 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces.egg-info/requires.txt +21 -0
- lsdo_function_spaces-1.0.0/lsdo_function_spaces.egg-info/top_level.txt +1 -0
- lsdo_function_spaces-1.0.0/pyproject.toml +86 -0
- lsdo_function_spaces-1.0.0/release_notes.md +55 -0
- lsdo_function_spaces-1.0.0/setup.cfg +4 -0
- lsdo_function_spaces-1.0.0/tests/conftest.py +23 -0
- lsdo_function_spaces-1.0.0/tests/test_b_spline_space.py +215 -0
- lsdo_function_spaces-1.0.0/tests/test_backward_compatibility.py +27 -0
- lsdo_function_spaces-1.0.0/tests/test_file_io.py +177 -0
- lsdo_function_spaces-1.0.0/tests/test_function.py +223 -0
- lsdo_function_spaces-1.0.0/tests/test_function_set.py +254 -0
- lsdo_function_spaces-1.0.0/tests/test_function_set_space.py +88 -0
- lsdo_function_spaces-1.0.0/tests/test_jax_bsplines.py +78 -0
- lsdo_function_spaces-1.0.0/tests/test_optimization.py +89 -0
- lsdo_function_spaces-1.0.0/tests/test_optimized_projection_and_factories.py +171 -0
- lsdo_function_spaces-1.0.0/tests/test_plotting.py +98 -0
- lsdo_function_spaces-1.0.0/tests/test_projection.py +186 -0
- lsdo_function_spaces-1.0.0/tests/test_spaces.py +183 -0
- lsdo_function_spaces-1.0.0/tests/test_utilities.py +122 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
include LICENSE.txt README.md pyproject.toml release_notes.md
|
|
2
|
+
recursive-include lsdo_function_spaces *.py
|
|
3
|
+
recursive-include tests *.py
|
|
4
|
+
recursive-exclude scratch *
|
|
5
|
+
recursive-exclude docs *
|
|
6
|
+
recursive-exclude examples *
|
|
7
|
+
recursive-exclude stored_files *
|
|
8
|
+
global-exclude __pycache__
|
|
9
|
+
global-exclude *.py[co]
|
|
10
|
+
global-exclude .DS_Store
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lsdo_function_spaces
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A package for functional representation and function spaces in multidisciplinary design optimization.
|
|
5
|
+
Author-email: Andrew Fletcher <afletcher168@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Documentation, https://lsdo-function-spaces.readthedocs.io/en/latest/
|
|
8
|
+
Project-URL: Repository, https://github.com/LSDOlab/lsdo_function_spaces
|
|
9
|
+
Project-URL: Issue Tracker, https://github.com/LSDOlab/lsdo_function_spaces/issues
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE.txt
|
|
22
|
+
Requires-Dist: numpy
|
|
23
|
+
Requires-Dist: scipy
|
|
24
|
+
Requires-Dist: pyvista
|
|
25
|
+
Requires-Dist: joblib
|
|
26
|
+
Requires-Dist: pandas
|
|
27
|
+
Requires-Dist: scikit-learn
|
|
28
|
+
Requires-Dist: jax
|
|
29
|
+
Provides-Extra: test
|
|
30
|
+
Requires-Dist: pytest; extra == "test"
|
|
31
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
32
|
+
Provides-Extra: docs
|
|
33
|
+
Requires-Dist: myst-nb; extra == "docs"
|
|
34
|
+
Requires-Dist: sphinx>=7.0; extra == "docs"
|
|
35
|
+
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
36
|
+
Requires-Dist: sphinx-copybutton; extra == "docs"
|
|
37
|
+
Requires-Dist: sphinx-autoapi>=3.0; extra == "docs"
|
|
38
|
+
Requires-Dist: numpydoc; extra == "docs"
|
|
39
|
+
Requires-Dist: gitpython; extra == "docs"
|
|
40
|
+
Requires-Dist: sphinxcontrib-bibtex; extra == "docs"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
# lsdo_function_spaces
|
|
44
|
+
|
|
45
|
+
[](https://lsdo-function-spaces.readthedocs.io/en/latest/?badge=latest)
|
|
46
|
+
[](https://github.com/LSDOlab/lsdo_function_spaces/actions)
|
|
47
|
+

|
|
48
|
+
[](LICENSE.txt)
|
|
49
|
+
|
|
50
|
+
**lsdo_function_spaces** is a pure-Python library for constructing continuous, high-dimensional, differentiable function representations (B-splines, tensor-product splines, scattered data spaces, and multivariate polynomials) tailored for gradient-based Multidisciplinary Design Optimization (MDO) and scientific computing.
|
|
51
|
+
|
|
52
|
+
Developed by the [Large-Scale Design Optimization (LSDO) Lab](https://lsdo.eng.ucsd.edu/) at the University of California, San Diego.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Key Features
|
|
57
|
+
|
|
58
|
+
* **Differentiable Function Spaces**: Unifies Cox-de Boor B-spline curves, surfaces, and volumes, Shepard inverse distance weighting (IDW), radial basis functions (RBF), and multivariate polynomials under an extensible functional abstraction.
|
|
59
|
+
* **100% Pure Python & JAX Accelerated**: Zero Cython or C compiler dependencies. High-performance vectorized evaluation and projection algorithms implemented cleanly in NumPy with optional JAX JIT acceleration.
|
|
60
|
+
* **Vectorized Inverse Point Projection**: Robust, vectorized Gauss-Newton and Levenberg-Marquardt algorithms with active-set bounds handling for projecting point clouds onto parametric spline curves, surfaces, and volumes.
|
|
61
|
+
* **End-to-End CSDL Graph Integration**: Custom Vector-Jacobian Products (VJPs) and automatic differentiation through `csdl_alpha`, enabling exact analytic adjoint sensitivities across complex computational graphs.
|
|
62
|
+
* **Interactive & Headless 3D Visualization**: Native PyVista support for visualizing spline control meshes, evaluated surface geometries, and discrete point clouds.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Architecture Overview
|
|
67
|
+
|
|
68
|
+
| Subpackage | Key Classes / Functions | Description |
|
|
69
|
+
|:---|:---|:---|
|
|
70
|
+
| **`lsdo_function_spaces.core.spaces`** | `BSplineSpace`, `FunctionSpace`, `ShepardSpace`, `PolynomialSpace`, `RBFSpace` | Core function space representations, basis function evaluations, and tensor-product constructions. |
|
|
71
|
+
| **`lsdo_function_spaces.core.function`** | `Function`, `FunctionSet` | Concrete functional instances binding coefficient vectors to function spaces, supporting evaluation and composition. |
|
|
72
|
+
| **`lsdo_function_spaces.core.spaces.non_cython_bsplines`** | `project_points_gauss_newton_numpy`, `project_points_lm_numpy`, `LMParams` | Vectorized inverse point projection engines utilizing active-set Levenberg-Marquardt and Gauss-Newton solvers. |
|
|
73
|
+
| **`lsdo_function_spaces.core.b_spline_csdl_custom_ops`** | Custom CSDL evaluation operations | Differentiable computational graph operations providing exact forward and reverse-mode derivative evaluations. |
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Quickstart
|
|
78
|
+
|
|
79
|
+
### Creating and Evaluating a B-spline Surface
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
import numpy as np
|
|
83
|
+
import csdl_alpha as csdl
|
|
84
|
+
from lsdo_function_spaces import BSplineSpace, Function
|
|
85
|
+
|
|
86
|
+
# 1. Define a 2D B-spline function space (degrees 3x3, 6x6 control points)
|
|
87
|
+
space = BSplineSpace(
|
|
88
|
+
num_dimensions=2,
|
|
89
|
+
order=(4, 4),
|
|
90
|
+
num_coefficients=(6, 6),
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# 2. Assign control point coefficients (e.g. parabolic saddle surface)
|
|
94
|
+
u = np.linspace(0, 1, 6)
|
|
95
|
+
v = np.linspace(0, 1, 6)
|
|
96
|
+
U, V = np.meshgrid(u, v, indexing="ij")
|
|
97
|
+
coefficients = np.stack([U, V, U**2 - V**2], axis=-1).reshape(-1, 3)
|
|
98
|
+
|
|
99
|
+
func = Function(space=space, coefficients=coefficients)
|
|
100
|
+
|
|
101
|
+
# 3. Evaluate surface at query parametric coordinates
|
|
102
|
+
eval_pts = np.array([
|
|
103
|
+
[0.2, 0.3],
|
|
104
|
+
[0.5, 0.5],
|
|
105
|
+
[0.8, 0.9],
|
|
106
|
+
])
|
|
107
|
+
physical_coords = func.evaluate(eval_pts)
|
|
108
|
+
print("Evaluated physical coordinates:\n", physical_coords)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Inverse Parametric Point Projection
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
import numpy as np
|
|
115
|
+
from lsdo_function_spaces.core.spaces.non_cython_bsplines.b_spline_patch_projection_optimized import (
|
|
116
|
+
project_points_lm_numpy,
|
|
117
|
+
LMParams,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
# Project arbitrary 3D points onto a B-spline surface patch
|
|
121
|
+
points = np.array([[0.25, 0.35, 0.1]])
|
|
122
|
+
u0s = np.array([[0.5, 0.5]]) # Initial parametric guess
|
|
123
|
+
|
|
124
|
+
u_opt, converged, lam, res = project_points_lm_numpy(
|
|
125
|
+
points=points,
|
|
126
|
+
u0s=u0s,
|
|
127
|
+
coeffs=coefficients,
|
|
128
|
+
degrees=(3, 3),
|
|
129
|
+
knot_vectors=space.knot_vectors,
|
|
130
|
+
params=LMParams(max_iter=50, tol_grad=1e-8),
|
|
131
|
+
)
|
|
132
|
+
print("Converged parametric coordinate:", u_opt)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Installation
|
|
138
|
+
|
|
139
|
+
### Prerequisites & Installation
|
|
140
|
+
`lsdo_function_spaces` requires Python $\ge 3.9$ and standard scientific Python packages:
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
# 1. Install prerequisites
|
|
144
|
+
pip install numpy scipy jax networkx
|
|
145
|
+
pip install git+https://github.com/LSDOlab/CSDL_alpha.git@dev_andrew
|
|
146
|
+
|
|
147
|
+
# 2. Install lsdo_function_spaces (User)
|
|
148
|
+
pip install lsdo_function_spaces
|
|
149
|
+
# Or install development version directly from GitHub:
|
|
150
|
+
pip install git+https://github.com/LSDOlab/lsdo_function_spaces.git
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### For Developers
|
|
154
|
+
Clone the repository and install in editable mode with testing and documentation dependencies:
|
|
155
|
+
```sh
|
|
156
|
+
git clone https://github.com/LSDOlab/lsdo_function_spaces.git
|
|
157
|
+
cd lsdo_function_spaces
|
|
158
|
+
pip install -e ".[test,docs]"
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Testing
|
|
164
|
+
|
|
165
|
+
Run the full test suite with coverage:
|
|
166
|
+
```sh
|
|
167
|
+
pytest -v tests/ --cov=lsdo_function_spaces --cov-report=term-missing
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
For environments without a physical display (e.g. CI runners), run with `xvfb`:
|
|
171
|
+
```sh
|
|
172
|
+
xvfb-run --auto-servernum pytest -v tests/
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Documentation
|
|
178
|
+
|
|
179
|
+
Build the HTML documentation locally:
|
|
180
|
+
```sh
|
|
181
|
+
sphinx-build -b html docs docs/_build/html -q -W
|
|
182
|
+
```
|
|
183
|
+
View the generated documentation by opening `docs/_build/html/index.html` in any web browser.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## License
|
|
188
|
+
|
|
189
|
+
This project is licensed under the terms of the **GNU Lesser General Public License v3.0** ([LGPL-3.0](LICENSE.txt)).
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# lsdo_function_spaces
|
|
2
|
+
|
|
3
|
+
[](https://lsdo-function-spaces.readthedocs.io/en/latest/?badge=latest)
|
|
4
|
+
[](https://github.com/LSDOlab/lsdo_function_spaces/actions)
|
|
5
|
+

|
|
6
|
+
[](LICENSE.txt)
|
|
7
|
+
|
|
8
|
+
**lsdo_function_spaces** is a pure-Python library for constructing continuous, high-dimensional, differentiable function representations (B-splines, tensor-product splines, scattered data spaces, and multivariate polynomials) tailored for gradient-based Multidisciplinary Design Optimization (MDO) and scientific computing.
|
|
9
|
+
|
|
10
|
+
Developed by the [Large-Scale Design Optimization (LSDO) Lab](https://lsdo.eng.ucsd.edu/) at the University of California, San Diego.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Key Features
|
|
15
|
+
|
|
16
|
+
* **Differentiable Function Spaces**: Unifies Cox-de Boor B-spline curves, surfaces, and volumes, Shepard inverse distance weighting (IDW), radial basis functions (RBF), and multivariate polynomials under an extensible functional abstraction.
|
|
17
|
+
* **100% Pure Python & JAX Accelerated**: Zero Cython or C compiler dependencies. High-performance vectorized evaluation and projection algorithms implemented cleanly in NumPy with optional JAX JIT acceleration.
|
|
18
|
+
* **Vectorized Inverse Point Projection**: Robust, vectorized Gauss-Newton and Levenberg-Marquardt algorithms with active-set bounds handling for projecting point clouds onto parametric spline curves, surfaces, and volumes.
|
|
19
|
+
* **End-to-End CSDL Graph Integration**: Custom Vector-Jacobian Products (VJPs) and automatic differentiation through `csdl_alpha`, enabling exact analytic adjoint sensitivities across complex computational graphs.
|
|
20
|
+
* **Interactive & Headless 3D Visualization**: Native PyVista support for visualizing spline control meshes, evaluated surface geometries, and discrete point clouds.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Architecture Overview
|
|
25
|
+
|
|
26
|
+
| Subpackage | Key Classes / Functions | Description |
|
|
27
|
+
|:---|:---|:---|
|
|
28
|
+
| **`lsdo_function_spaces.core.spaces`** | `BSplineSpace`, `FunctionSpace`, `ShepardSpace`, `PolynomialSpace`, `RBFSpace` | Core function space representations, basis function evaluations, and tensor-product constructions. |
|
|
29
|
+
| **`lsdo_function_spaces.core.function`** | `Function`, `FunctionSet` | Concrete functional instances binding coefficient vectors to function spaces, supporting evaluation and composition. |
|
|
30
|
+
| **`lsdo_function_spaces.core.spaces.non_cython_bsplines`** | `project_points_gauss_newton_numpy`, `project_points_lm_numpy`, `LMParams` | Vectorized inverse point projection engines utilizing active-set Levenberg-Marquardt and Gauss-Newton solvers. |
|
|
31
|
+
| **`lsdo_function_spaces.core.b_spline_csdl_custom_ops`** | Custom CSDL evaluation operations | Differentiable computational graph operations providing exact forward and reverse-mode derivative evaluations. |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Quickstart
|
|
36
|
+
|
|
37
|
+
### Creating and Evaluating a B-spline Surface
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import numpy as np
|
|
41
|
+
import csdl_alpha as csdl
|
|
42
|
+
from lsdo_function_spaces import BSplineSpace, Function
|
|
43
|
+
|
|
44
|
+
# 1. Define a 2D B-spline function space (degrees 3x3, 6x6 control points)
|
|
45
|
+
space = BSplineSpace(
|
|
46
|
+
num_dimensions=2,
|
|
47
|
+
order=(4, 4),
|
|
48
|
+
num_coefficients=(6, 6),
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# 2. Assign control point coefficients (e.g. parabolic saddle surface)
|
|
52
|
+
u = np.linspace(0, 1, 6)
|
|
53
|
+
v = np.linspace(0, 1, 6)
|
|
54
|
+
U, V = np.meshgrid(u, v, indexing="ij")
|
|
55
|
+
coefficients = np.stack([U, V, U**2 - V**2], axis=-1).reshape(-1, 3)
|
|
56
|
+
|
|
57
|
+
func = Function(space=space, coefficients=coefficients)
|
|
58
|
+
|
|
59
|
+
# 3. Evaluate surface at query parametric coordinates
|
|
60
|
+
eval_pts = np.array([
|
|
61
|
+
[0.2, 0.3],
|
|
62
|
+
[0.5, 0.5],
|
|
63
|
+
[0.8, 0.9],
|
|
64
|
+
])
|
|
65
|
+
physical_coords = func.evaluate(eval_pts)
|
|
66
|
+
print("Evaluated physical coordinates:\n", physical_coords)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Inverse Parametric Point Projection
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
import numpy as np
|
|
73
|
+
from lsdo_function_spaces.core.spaces.non_cython_bsplines.b_spline_patch_projection_optimized import (
|
|
74
|
+
project_points_lm_numpy,
|
|
75
|
+
LMParams,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# Project arbitrary 3D points onto a B-spline surface patch
|
|
79
|
+
points = np.array([[0.25, 0.35, 0.1]])
|
|
80
|
+
u0s = np.array([[0.5, 0.5]]) # Initial parametric guess
|
|
81
|
+
|
|
82
|
+
u_opt, converged, lam, res = project_points_lm_numpy(
|
|
83
|
+
points=points,
|
|
84
|
+
u0s=u0s,
|
|
85
|
+
coeffs=coefficients,
|
|
86
|
+
degrees=(3, 3),
|
|
87
|
+
knot_vectors=space.knot_vectors,
|
|
88
|
+
params=LMParams(max_iter=50, tol_grad=1e-8),
|
|
89
|
+
)
|
|
90
|
+
print("Converged parametric coordinate:", u_opt)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Installation
|
|
96
|
+
|
|
97
|
+
### Prerequisites & Installation
|
|
98
|
+
`lsdo_function_spaces` requires Python $\ge 3.9$ and standard scientific Python packages:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
# 1. Install prerequisites
|
|
102
|
+
pip install numpy scipy jax networkx
|
|
103
|
+
pip install git+https://github.com/LSDOlab/CSDL_alpha.git@dev_andrew
|
|
104
|
+
|
|
105
|
+
# 2. Install lsdo_function_spaces (User)
|
|
106
|
+
pip install lsdo_function_spaces
|
|
107
|
+
# Or install development version directly from GitHub:
|
|
108
|
+
pip install git+https://github.com/LSDOlab/lsdo_function_spaces.git
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### For Developers
|
|
112
|
+
Clone the repository and install in editable mode with testing and documentation dependencies:
|
|
113
|
+
```sh
|
|
114
|
+
git clone https://github.com/LSDOlab/lsdo_function_spaces.git
|
|
115
|
+
cd lsdo_function_spaces
|
|
116
|
+
pip install -e ".[test,docs]"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Testing
|
|
122
|
+
|
|
123
|
+
Run the full test suite with coverage:
|
|
124
|
+
```sh
|
|
125
|
+
pytest -v tests/ --cov=lsdo_function_spaces --cov-report=term-missing
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
For environments without a physical display (e.g. CI runners), run with `xvfb`:
|
|
129
|
+
```sh
|
|
130
|
+
xvfb-run --auto-servernum pytest -v tests/
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Documentation
|
|
136
|
+
|
|
137
|
+
Build the HTML documentation locally:
|
|
138
|
+
```sh
|
|
139
|
+
sphinx-build -b html docs docs/_build/html -q -W
|
|
140
|
+
```
|
|
141
|
+
View the generated documentation by opening `docs/_build/html/index.html` in any web browser.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
This project is licensed under the terms of the **GNU Lesser General Public License v3.0** ([LGPL-3.0](LICENSE.txt)).
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""lsdo_function_spaces: Functional representations and function spaces for MDO."""
|
|
2
|
+
|
|
3
|
+
import multiprocessing
|
|
4
|
+
|
|
5
|
+
__version__ = "1.0.0"
|
|
6
|
+
num_workers = multiprocessing.cpu_count()
|
|
7
|
+
|
|
8
|
+
# Core representations
|
|
9
|
+
from .core.function import Function
|
|
10
|
+
from .core.function_set import FunctionSet
|
|
11
|
+
from .core.function_space import FunctionSpace, LinearFunctionSpace
|
|
12
|
+
from .core.function_set_space import FunctionSetSpace
|
|
13
|
+
|
|
14
|
+
# Function spaces
|
|
15
|
+
from .core.spaces.b_spline_space import BSplineSpace, BSplineSpaceNew
|
|
16
|
+
from .core.spaces.polynomial_space import PolynomialSpace
|
|
17
|
+
from .core.spaces.conditional_space import ConditionalSpace
|
|
18
|
+
from .core.spaces.idw_space import IDWFunctionSpace
|
|
19
|
+
from .core.spaces.constant_space import ConstantSpace
|
|
20
|
+
from .core.spaces.rbf_space import RBFFunctionSpace
|
|
21
|
+
from .core.spaces.tri_space import LinearTriangulationSpace
|
|
22
|
+
|
|
23
|
+
# Utilities
|
|
24
|
+
from .utils.plotting_functions import (
|
|
25
|
+
plot_points,
|
|
26
|
+
plot_curve,
|
|
27
|
+
plot_surface,
|
|
28
|
+
show_plot,
|
|
29
|
+
)
|
|
30
|
+
from .utils.file_io import import_file, import_file_patched
|
|
31
|
+
from .utils.utility_functions import (
|
|
32
|
+
create_b_spline_from_corners,
|
|
33
|
+
create_enclosure_block,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
# Operations
|
|
37
|
+
from .core.operations import operations
|
|
38
|
+
|
|
39
|
+
__all__ = [
|
|
40
|
+
"__version__",
|
|
41
|
+
"num_workers",
|
|
42
|
+
"Function",
|
|
43
|
+
"FunctionSet",
|
|
44
|
+
"FunctionSpace",
|
|
45
|
+
"LinearFunctionSpace",
|
|
46
|
+
"FunctionSetSpace",
|
|
47
|
+
"BSplineSpace",
|
|
48
|
+
"BSplineSpaceNew",
|
|
49
|
+
"PolynomialSpace",
|
|
50
|
+
"ConditionalSpace",
|
|
51
|
+
"ConstantSpace",
|
|
52
|
+
"IDWFunctionSpace",
|
|
53
|
+
"RBFFunctionSpace",
|
|
54
|
+
"LinearTriangulationSpace",
|
|
55
|
+
"plot_points",
|
|
56
|
+
"plot_curve",
|
|
57
|
+
"plot_surface",
|
|
58
|
+
"show_plot",
|
|
59
|
+
"import_file",
|
|
60
|
+
"import_file_patched",
|
|
61
|
+
"create_b_spline_from_corners",
|
|
62
|
+
"create_enclosure_block",
|
|
63
|
+
"operations",
|
|
64
|
+
]
|
|
File without changes
|