cubitpy 0.0.1__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.
- cubitpy-0.0.1/LICENSE +21 -0
- cubitpy-0.0.1/PKG-INFO +100 -0
- cubitpy-0.0.1/README.md +79 -0
- cubitpy-0.0.1/pyproject.toml +34 -0
- cubitpy-0.0.1/setup.cfg +4 -0
- cubitpy-0.0.1/src/CubitPy.egg-info/PKG-INFO +100 -0
- cubitpy-0.0.1/src/CubitPy.egg-info/SOURCES.txt +31 -0
- cubitpy-0.0.1/src/CubitPy.egg-info/dependency_links.txt +1 -0
- cubitpy-0.0.1/src/CubitPy.egg-info/requires.txt +10 -0
- cubitpy-0.0.1/src/CubitPy.egg-info/top_level.txt +2 -0
- cubitpy-0.0.1/src/cubitpy/__init__.py +34 -0
- cubitpy-0.0.1/src/cubitpy/conf.py +158 -0
- cubitpy-0.0.1/src/cubitpy/cubit_group.py +353 -0
- cubitpy-0.0.1/src/cubitpy/cubit_utility.py +49 -0
- cubitpy-0.0.1/src/cubitpy/cubit_wrapper/__init__.py +22 -0
- cubitpy-0.0.1/src/cubitpy/cubit_wrapper/cubit_wrapper_client.py +255 -0
- cubitpy-0.0.1/src/cubitpy/cubit_wrapper/cubit_wrapper_host.py +379 -0
- cubitpy-0.0.1/src/cubitpy/cubit_wrapper/cubit_wrapper_utility.py +60 -0
- cubitpy-0.0.1/src/cubitpy/cubitpy.py +441 -0
- cubitpy-0.0.1/src/cubitpy/cubitpy_to_dat.py +207 -0
- cubitpy-0.0.1/src/cubitpy/cubitpy_types.py +358 -0
- cubitpy-0.0.1/src/cubitpy/geometry_creation_functions.py +224 -0
- cubitpy-0.0.1/src/cubitpy/mesh_creation_functions.py +276 -0
- cubitpy-0.0.1/src/tutorial/__init__.py +25 -0
- cubitpy-0.0.1/src/tutorial/tutorial.py +250 -0
- cubitpy-0.0.1/tests/test_cubitpy.py +1604 -0
- cubitpy-0.0.1/tests/test_delete.py +38 -0
- cubitpy-0.0.1/tests/test_tutorial.py +48 -0
cubitpy-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-2025 CubitPy Authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
cubitpy-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cubitpy
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: CubitPy: Utility functions and 4C related functionality for the Cubit and Coreform python interface
|
|
5
|
+
Author-email: Ivo Steinbrecher <ivo.steinbrecher@unibw.de>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/imcs-compsim/cubitpy/
|
|
8
|
+
Project-URL: Issues, https://github.com/imcs-compsim/cubitpy/issues/
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: execnet==1.9.0
|
|
12
|
+
Requires-Dist: netCDF4
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: coverage; extra == "dev"
|
|
16
|
+
Requires-Dist: coverage-badge; extra == "dev"
|
|
17
|
+
Requires-Dist: setuptools; extra == "dev"
|
|
18
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
19
|
+
Requires-Dist: pytest; extra == "dev"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
[](https://github.com/imcs-compsim/cubitpy/actions/workflows/.github/workflows/build-test.yml)
|
|
23
|
+
|
|
24
|
+
# CubitPy
|
|
25
|
+
|
|
26
|
+
Utility functions and 4C related functionality for the Cubit and Coreform python interface,
|
|
27
|
+
Especially for the creation of input files for 4C.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
A tutorial can be found in the `/tutorial` directory.
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
If you are interested in contributing to CubitPy, we welcome your collaboration.
|
|
36
|
+
For general questions, feature request and bug reports please open an [issue](https://github.com/imcs-compsim/cubitpy/issues).
|
|
37
|
+
|
|
38
|
+
If you contribute actual code, fork the repository and make the changes in a feature branch.
|
|
39
|
+
Depending on the topic and amount of changes you also might want to open an [issue](https://github.com/imcs-compsim/cubitpy/issues).
|
|
40
|
+
To merge your changes into the CubitPy repository, create a pull request to the `main` branch.
|
|
41
|
+
A few things to keep in mind:
|
|
42
|
+
- It is highly encouraged to add tests covering the functionality of your changes, see the test suite in `tests/`.
|
|
43
|
+
- CubitPy uses `black` to format python code.
|
|
44
|
+
Make sure to apply `black` to the changed source files.
|
|
45
|
+
- Feel free to add yourself to the [CONTRIBUTORS](CONTRIBUTORS) file.
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
CubitPy is developed with `python3.12`.
|
|
50
|
+
Other versions of Python might lead to issues.
|
|
51
|
+
It is recommended to use a python environment container such as `conda` or `venv`.
|
|
52
|
+
- `conda`:
|
|
53
|
+
A [conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) environment can be created and loaded with
|
|
54
|
+
```bash
|
|
55
|
+
conda create -n cubitpy python=3.12
|
|
56
|
+
conda activate cubitpy
|
|
57
|
+
```
|
|
58
|
+
- `venv`: Chose an appropriate directory for this, e.g., `/home/user/opt`.
|
|
59
|
+
A virtual environment can be setup with
|
|
60
|
+
- On Debian systems the following packages have to be installed:
|
|
61
|
+
```bash
|
|
62
|
+
sudo apt-get install python3-venv python3-dev
|
|
63
|
+
```
|
|
64
|
+
- Create and load the environment
|
|
65
|
+
```bash
|
|
66
|
+
cd <path-to-env-folder>
|
|
67
|
+
python -m venv cubitpy-env
|
|
68
|
+
source cubitpy-env/bin/activate
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
To install `cubitpy` go to the repository root directory
|
|
72
|
+
```bash
|
|
73
|
+
cd path_to_cubitpy
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
And install `cubitpy` via `pip`
|
|
77
|
+
```bash
|
|
78
|
+
pip install .
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If you intend to actively develop `cubitpy`, install it in *editable mode*
|
|
82
|
+
```bash
|
|
83
|
+
pip install -e .
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
To run CubitPy it is required to set an environment variable with the path to the Cubit directory. This should be the "root" directory for the installation.
|
|
87
|
+
```bash
|
|
88
|
+
export CUBIT_ROOT=path_to_cubit_root_directory
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
To check if everything worked as expected, run the tests from within the `tests` directory
|
|
92
|
+
```bash
|
|
93
|
+
cd path_to_cubitpy/tests
|
|
94
|
+
pytest -q testing.py
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If you intend to actively develop CubitPy, please make sure to install the `pre-commit` hook within the python environment to follow our style guides:
|
|
98
|
+
```bash
|
|
99
|
+
pre-commit install
|
|
100
|
+
```
|
cubitpy-0.0.1/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
[](https://github.com/imcs-compsim/cubitpy/actions/workflows/.github/workflows/build-test.yml)
|
|
2
|
+
|
|
3
|
+
# CubitPy
|
|
4
|
+
|
|
5
|
+
Utility functions and 4C related functionality for the Cubit and Coreform python interface,
|
|
6
|
+
Especially for the creation of input files for 4C.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
A tutorial can be found in the `/tutorial` directory.
|
|
11
|
+
|
|
12
|
+
## Contributing
|
|
13
|
+
|
|
14
|
+
If you are interested in contributing to CubitPy, we welcome your collaboration.
|
|
15
|
+
For general questions, feature request and bug reports please open an [issue](https://github.com/imcs-compsim/cubitpy/issues).
|
|
16
|
+
|
|
17
|
+
If you contribute actual code, fork the repository and make the changes in a feature branch.
|
|
18
|
+
Depending on the topic and amount of changes you also might want to open an [issue](https://github.com/imcs-compsim/cubitpy/issues).
|
|
19
|
+
To merge your changes into the CubitPy repository, create a pull request to the `main` branch.
|
|
20
|
+
A few things to keep in mind:
|
|
21
|
+
- It is highly encouraged to add tests covering the functionality of your changes, see the test suite in `tests/`.
|
|
22
|
+
- CubitPy uses `black` to format python code.
|
|
23
|
+
Make sure to apply `black` to the changed source files.
|
|
24
|
+
- Feel free to add yourself to the [CONTRIBUTORS](CONTRIBUTORS) file.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
CubitPy is developed with `python3.12`.
|
|
29
|
+
Other versions of Python might lead to issues.
|
|
30
|
+
It is recommended to use a python environment container such as `conda` or `venv`.
|
|
31
|
+
- `conda`:
|
|
32
|
+
A [conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) environment can be created and loaded with
|
|
33
|
+
```bash
|
|
34
|
+
conda create -n cubitpy python=3.12
|
|
35
|
+
conda activate cubitpy
|
|
36
|
+
```
|
|
37
|
+
- `venv`: Chose an appropriate directory for this, e.g., `/home/user/opt`.
|
|
38
|
+
A virtual environment can be setup with
|
|
39
|
+
- On Debian systems the following packages have to be installed:
|
|
40
|
+
```bash
|
|
41
|
+
sudo apt-get install python3-venv python3-dev
|
|
42
|
+
```
|
|
43
|
+
- Create and load the environment
|
|
44
|
+
```bash
|
|
45
|
+
cd <path-to-env-folder>
|
|
46
|
+
python -m venv cubitpy-env
|
|
47
|
+
source cubitpy-env/bin/activate
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
To install `cubitpy` go to the repository root directory
|
|
51
|
+
```bash
|
|
52
|
+
cd path_to_cubitpy
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
And install `cubitpy` via `pip`
|
|
56
|
+
```bash
|
|
57
|
+
pip install .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If you intend to actively develop `cubitpy`, install it in *editable mode*
|
|
61
|
+
```bash
|
|
62
|
+
pip install -e .
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
To run CubitPy it is required to set an environment variable with the path to the Cubit directory. This should be the "root" directory for the installation.
|
|
66
|
+
```bash
|
|
67
|
+
export CUBIT_ROOT=path_to_cubit_root_directory
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
To check if everything worked as expected, run the tests from within the `tests` directory
|
|
71
|
+
```bash
|
|
72
|
+
cd path_to_cubitpy/tests
|
|
73
|
+
pytest -q testing.py
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
If you intend to actively develop CubitPy, please make sure to install the `pre-commit` hook within the python environment to follow our style guides:
|
|
77
|
+
```bash
|
|
78
|
+
pre-commit install
|
|
79
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cubitpy"
|
|
7
|
+
authors = [
|
|
8
|
+
{name = "Ivo Steinbrecher", email = "ivo.steinbrecher@unibw.de"},
|
|
9
|
+
]
|
|
10
|
+
description = "CubitPy: Utility functions and 4C related functionality for the Cubit and Coreform python interface"
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
license = "MIT"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"execnet==1.9.0",
|
|
15
|
+
"netCDF4",
|
|
16
|
+
"numpy"
|
|
17
|
+
]
|
|
18
|
+
version = "0.0.1"
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Repository = "https://github.com/imcs-compsim/cubitpy/"
|
|
22
|
+
Issues = "https://github.com/imcs-compsim/cubitpy/issues/"
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
dev = [
|
|
26
|
+
"coverage",
|
|
27
|
+
"coverage-badge",
|
|
28
|
+
"setuptools", # Needed for coverage-badge
|
|
29
|
+
"pre-commit",
|
|
30
|
+
"pytest"
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[tool.pytest.ini_options]
|
|
34
|
+
testpaths = ["tests"]
|
cubitpy-0.0.1/setup.cfg
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cubitpy
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: CubitPy: Utility functions and 4C related functionality for the Cubit and Coreform python interface
|
|
5
|
+
Author-email: Ivo Steinbrecher <ivo.steinbrecher@unibw.de>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/imcs-compsim/cubitpy/
|
|
8
|
+
Project-URL: Issues, https://github.com/imcs-compsim/cubitpy/issues/
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: execnet==1.9.0
|
|
12
|
+
Requires-Dist: netCDF4
|
|
13
|
+
Requires-Dist: numpy
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: coverage; extra == "dev"
|
|
16
|
+
Requires-Dist: coverage-badge; extra == "dev"
|
|
17
|
+
Requires-Dist: setuptools; extra == "dev"
|
|
18
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
19
|
+
Requires-Dist: pytest; extra == "dev"
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
[](https://github.com/imcs-compsim/cubitpy/actions/workflows/.github/workflows/build-test.yml)
|
|
23
|
+
|
|
24
|
+
# CubitPy
|
|
25
|
+
|
|
26
|
+
Utility functions and 4C related functionality for the Cubit and Coreform python interface,
|
|
27
|
+
Especially for the creation of input files for 4C.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
A tutorial can be found in the `/tutorial` directory.
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
If you are interested in contributing to CubitPy, we welcome your collaboration.
|
|
36
|
+
For general questions, feature request and bug reports please open an [issue](https://github.com/imcs-compsim/cubitpy/issues).
|
|
37
|
+
|
|
38
|
+
If you contribute actual code, fork the repository and make the changes in a feature branch.
|
|
39
|
+
Depending on the topic and amount of changes you also might want to open an [issue](https://github.com/imcs-compsim/cubitpy/issues).
|
|
40
|
+
To merge your changes into the CubitPy repository, create a pull request to the `main` branch.
|
|
41
|
+
A few things to keep in mind:
|
|
42
|
+
- It is highly encouraged to add tests covering the functionality of your changes, see the test suite in `tests/`.
|
|
43
|
+
- CubitPy uses `black` to format python code.
|
|
44
|
+
Make sure to apply `black` to the changed source files.
|
|
45
|
+
- Feel free to add yourself to the [CONTRIBUTORS](CONTRIBUTORS) file.
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
CubitPy is developed with `python3.12`.
|
|
50
|
+
Other versions of Python might lead to issues.
|
|
51
|
+
It is recommended to use a python environment container such as `conda` or `venv`.
|
|
52
|
+
- `conda`:
|
|
53
|
+
A [conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html) environment can be created and loaded with
|
|
54
|
+
```bash
|
|
55
|
+
conda create -n cubitpy python=3.12
|
|
56
|
+
conda activate cubitpy
|
|
57
|
+
```
|
|
58
|
+
- `venv`: Chose an appropriate directory for this, e.g., `/home/user/opt`.
|
|
59
|
+
A virtual environment can be setup with
|
|
60
|
+
- On Debian systems the following packages have to be installed:
|
|
61
|
+
```bash
|
|
62
|
+
sudo apt-get install python3-venv python3-dev
|
|
63
|
+
```
|
|
64
|
+
- Create and load the environment
|
|
65
|
+
```bash
|
|
66
|
+
cd <path-to-env-folder>
|
|
67
|
+
python -m venv cubitpy-env
|
|
68
|
+
source cubitpy-env/bin/activate
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
To install `cubitpy` go to the repository root directory
|
|
72
|
+
```bash
|
|
73
|
+
cd path_to_cubitpy
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
And install `cubitpy` via `pip`
|
|
77
|
+
```bash
|
|
78
|
+
pip install .
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If you intend to actively develop `cubitpy`, install it in *editable mode*
|
|
82
|
+
```bash
|
|
83
|
+
pip install -e .
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
To run CubitPy it is required to set an environment variable with the path to the Cubit directory. This should be the "root" directory for the installation.
|
|
87
|
+
```bash
|
|
88
|
+
export CUBIT_ROOT=path_to_cubit_root_directory
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
To check if everything worked as expected, run the tests from within the `tests` directory
|
|
92
|
+
```bash
|
|
93
|
+
cd path_to_cubitpy/tests
|
|
94
|
+
pytest -q testing.py
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If you intend to actively develop CubitPy, please make sure to install the `pre-commit` hook within the python environment to follow our style guides:
|
|
98
|
+
```bash
|
|
99
|
+
pre-commit install
|
|
100
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/CubitPy.egg-info/PKG-INFO
|
|
5
|
+
src/CubitPy.egg-info/SOURCES.txt
|
|
6
|
+
src/CubitPy.egg-info/dependency_links.txt
|
|
7
|
+
src/CubitPy.egg-info/requires.txt
|
|
8
|
+
src/CubitPy.egg-info/top_level.txt
|
|
9
|
+
src/cubitpy/__init__.py
|
|
10
|
+
src/cubitpy/conf.py
|
|
11
|
+
src/cubitpy/cubit_group.py
|
|
12
|
+
src/cubitpy/cubit_utility.py
|
|
13
|
+
src/cubitpy/cubitpy.py
|
|
14
|
+
src/cubitpy/cubitpy_to_dat.py
|
|
15
|
+
src/cubitpy/cubitpy_types.py
|
|
16
|
+
src/cubitpy/geometry_creation_functions.py
|
|
17
|
+
src/cubitpy/mesh_creation_functions.py
|
|
18
|
+
src/cubitpy.egg-info/PKG-INFO
|
|
19
|
+
src/cubitpy.egg-info/SOURCES.txt
|
|
20
|
+
src/cubitpy.egg-info/dependency_links.txt
|
|
21
|
+
src/cubitpy.egg-info/requires.txt
|
|
22
|
+
src/cubitpy.egg-info/top_level.txt
|
|
23
|
+
src/cubitpy/cubit_wrapper/__init__.py
|
|
24
|
+
src/cubitpy/cubit_wrapper/cubit_wrapper_client.py
|
|
25
|
+
src/cubitpy/cubit_wrapper/cubit_wrapper_host.py
|
|
26
|
+
src/cubitpy/cubit_wrapper/cubit_wrapper_utility.py
|
|
27
|
+
src/tutorial/__init__.py
|
|
28
|
+
src/tutorial/tutorial.py
|
|
29
|
+
tests/test_cubitpy.py
|
|
30
|
+
tests/test_delete.py
|
|
31
|
+
tests/test_tutorial.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# The MIT License (MIT)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2018-2025 CubitPy Authors
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
|
13
|
+
# all copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
# THE SOFTWARE.
|
|
22
|
+
"""This module contains extensions and utility functions for the cubit python
|
|
23
|
+
interface."""
|
|
24
|
+
|
|
25
|
+
from cubitpy.conf import cupy
|
|
26
|
+
from cubitpy.cubitpy import CubitPy
|
|
27
|
+
|
|
28
|
+
# Define the items that will be exported by default.
|
|
29
|
+
__all__ = [
|
|
30
|
+
# cubit options.
|
|
31
|
+
"cupy",
|
|
32
|
+
# Cubit objects.
|
|
33
|
+
"CubitPy",
|
|
34
|
+
]
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# The MIT License (MIT)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2018-2025 CubitPy Authors
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
|
13
|
+
# all copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
# THE SOFTWARE.
|
|
22
|
+
"""This module defines a global object that manages all kind of stuff regarding
|
|
23
|
+
cubitpy."""
|
|
24
|
+
|
|
25
|
+
import getpass
|
|
26
|
+
import glob
|
|
27
|
+
import os
|
|
28
|
+
import shutil
|
|
29
|
+
from sys import platform
|
|
30
|
+
|
|
31
|
+
from cubitpy.cubitpy_types import (
|
|
32
|
+
BoundaryConditionType,
|
|
33
|
+
CubitItems,
|
|
34
|
+
ElementType,
|
|
35
|
+
FiniteElementObject,
|
|
36
|
+
GeometryType,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_path(environment_variable, test_function, *, throw_error=True):
|
|
41
|
+
"""Check if he environment variable is set and the path exits."""
|
|
42
|
+
if environment_variable in os.environ.keys():
|
|
43
|
+
if test_function(os.environ[environment_variable]):
|
|
44
|
+
return os.environ[environment_variable]
|
|
45
|
+
|
|
46
|
+
# No valid path found or given.
|
|
47
|
+
if throw_error:
|
|
48
|
+
raise ValueError("Path for {} not found!".format(environment_variable))
|
|
49
|
+
else:
|
|
50
|
+
return None
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class CubitOptions(object):
|
|
54
|
+
"""Object for types in cubitpy."""
|
|
55
|
+
|
|
56
|
+
def __init__(self):
|
|
57
|
+
# Temporary directory for cubitpy.
|
|
58
|
+
self.temp_dir = os.path.join(
|
|
59
|
+
"/tmp/cubitpy_{}".format(getpass.getuser()), # nosec
|
|
60
|
+
"pid_{}".format(os.getpid()),
|
|
61
|
+
)
|
|
62
|
+
self.temp_log = os.path.join(self.temp_dir, "cubitpy.log")
|
|
63
|
+
|
|
64
|
+
# Check if temp path exits, if not create it.
|
|
65
|
+
os.makedirs(self.temp_dir, exist_ok=True)
|
|
66
|
+
|
|
67
|
+
# Geometry types.
|
|
68
|
+
self.geometry = GeometryType
|
|
69
|
+
|
|
70
|
+
# Finite element types.
|
|
71
|
+
self.finite_element_object = FiniteElementObject
|
|
72
|
+
|
|
73
|
+
# Element shape types.
|
|
74
|
+
self.element_type = ElementType
|
|
75
|
+
|
|
76
|
+
# Cubit internal items.
|
|
77
|
+
self.cubit_items = CubitItems
|
|
78
|
+
|
|
79
|
+
# Boundary condition type.
|
|
80
|
+
self.bc_type = BoundaryConditionType
|
|
81
|
+
|
|
82
|
+
# Tolerance for geometry.
|
|
83
|
+
self.eps_pos = 1e-10
|
|
84
|
+
|
|
85
|
+
@staticmethod
|
|
86
|
+
def get_cubit_root_path(**kwargs):
|
|
87
|
+
"""Get Path to cubit root directory."""
|
|
88
|
+
return get_path("CUBIT_ROOT", os.path.isdir, **kwargs)
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def get_cubit_exe_path(cls, **kwargs):
|
|
92
|
+
"""Get Path to cubit executable."""
|
|
93
|
+
cubit_root = cls.get_cubit_root_path(**kwargs)
|
|
94
|
+
if platform == "linux" or platform == "linux2":
|
|
95
|
+
if cupy.is_coreform():
|
|
96
|
+
return os.path.join(cubit_root, "bin", "coreform_cubit")
|
|
97
|
+
else:
|
|
98
|
+
return os.path.join(cubit_root, "cubit")
|
|
99
|
+
elif platform == "darwin":
|
|
100
|
+
if cupy.is_coreform():
|
|
101
|
+
cubit_exe_name = cubit_root.split("/")[-1].split(".app")[0]
|
|
102
|
+
return os.path.join(cubit_root, "Contents/MacOS", cubit_exe_name)
|
|
103
|
+
else:
|
|
104
|
+
return os.path.join(cubit_root, "Contents/MacOS/Cubit")
|
|
105
|
+
else:
|
|
106
|
+
raise ValueError("Got unexpected platform")
|
|
107
|
+
|
|
108
|
+
@classmethod
|
|
109
|
+
def get_cubit_lib_path(cls, **kwargs):
|
|
110
|
+
"""Get Path to cubit lib directory."""
|
|
111
|
+
cubit_root = cls.get_cubit_root_path(**kwargs)
|
|
112
|
+
if platform == "linux" or platform == "linux2":
|
|
113
|
+
return os.path.join(cubit_root, "bin")
|
|
114
|
+
elif platform == "darwin":
|
|
115
|
+
if cls.is_coreform():
|
|
116
|
+
return os.path.join(cubit_root, "Contents/lib")
|
|
117
|
+
else:
|
|
118
|
+
return os.path.join(cubit_root, "Contents/MacOS")
|
|
119
|
+
else:
|
|
120
|
+
raise ValueError("Got unexpected platform")
|
|
121
|
+
|
|
122
|
+
@classmethod
|
|
123
|
+
def get_cubit_interpreter(cls):
|
|
124
|
+
"""Get the path to the python interpreter to be used for CubitPy."""
|
|
125
|
+
cubit_root = cls.get_cubit_root_path()
|
|
126
|
+
if cls.is_coreform():
|
|
127
|
+
pattern = "**/python3"
|
|
128
|
+
full_pattern = os.path.join(cubit_root, pattern)
|
|
129
|
+
python3_matches = glob.glob(full_pattern, recursive=True)
|
|
130
|
+
python3_files = [path for path in python3_matches if os.path.isfile(path)]
|
|
131
|
+
if not len(python3_files) == 1:
|
|
132
|
+
raise ValueError(
|
|
133
|
+
"Could not find the path to the cubit python interpreter"
|
|
134
|
+
)
|
|
135
|
+
cubit_python_interpreter = python3_files[0]
|
|
136
|
+
return cubit_python_interpreter
|
|
137
|
+
else:
|
|
138
|
+
if shutil.which("python2.7") is not None:
|
|
139
|
+
return "python2.7"
|
|
140
|
+
|
|
141
|
+
imcs_python2_path = "/imcs/public/compsim/opt/Python-2.7.18/python"
|
|
142
|
+
if os.path.exists(imcs_python2_path):
|
|
143
|
+
return imcs_python2_path
|
|
144
|
+
|
|
145
|
+
raise ValueError("Could not find a python2 interpreter")
|
|
146
|
+
|
|
147
|
+
@classmethod
|
|
148
|
+
def is_coreform(cls):
|
|
149
|
+
"""Return if the given path is a path to cubit coreform."""
|
|
150
|
+
cubit_root = cls.get_cubit_root_path()
|
|
151
|
+
if "15.2" in cubit_root:
|
|
152
|
+
return False
|
|
153
|
+
else:
|
|
154
|
+
return True
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
# Global object with options for cubitpy.
|
|
158
|
+
cupy = CubitOptions()
|