Skip to content

Commit a9ea7a9

Browse files
committed
Improve readme.
2 parents fc7d89a + 0ec3758 commit a9ea7a9

File tree

3 files changed

+78
-55
lines changed

3 files changed

+78
-55
lines changed

README.md

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# cutde
2-
31
<p align=center>
42
<a target="_blank" href="https://www.python.org/downloads/" title="Python version"><img src="https://img.shields.io/badge/python-%3E=_3.6-green.svg"></a>
53
<a target="_blank" href="https://pypi.org/project/cutde/" title="PyPI version"><img src="https://img.shields.io/pypi/v/cutde?logo=pypi"></a>
@@ -9,17 +7,35 @@
97

108
# Python + CUDA TDEs from Nikkhoo and Walter 2015
119

12-
CUDA and OpenCL-enabled fullspace triangle dislocation elements. Benchmarked at 130 million TDEs per second. Based on the [original MATLAB code from Nikhoo and Walter 2015.](https://volcanodeformation.com/software).
10+
CUDA and OpenCL-enabled fullspace triangle dislocation elements. Benchmarked at 130 million TDEs per second. Based on the [original MATLAB code from Nikhoo and Walter 2015.](https://volcanodeformation.com/software)
1311

1412
See below for usage and installation instructions.
1513

16-
### An example
14+
<!--ts-->
15+
* [Python + CUDA TDEs from Nikkhoo and Walter 2015](#python--cuda-tdes-from-nikkhoo-and-walter-2015)
16+
* [Usage documentation](#usage-documentation)
17+
* [I want stress.](#i-want-stress)
18+
* [All pairs](#all-pairs)
19+
* [Installation](#installation)
20+
* [PyCUDA](#pycuda)
21+
* [Mac OS X](#mac-os-x)
22+
* [Ubuntu + PyOpenCL/PoCL](#ubuntu--pyopenclpocl)
23+
* [Ubuntu + PyOpenCL with system drivers**](#ubuntu--pyopencl-with-system-drivers)
24+
* [Windows](#windows)
25+
* [Something else](#something-else)
26+
* [Why can't I use Apple CPU OpenCL?](#why-cant-i-use-apple-cpu-opencl)
27+
* [Development](#development)
1728

18-
```
29+
<!-- Added by: tbent, at: Mon 05 Apr 2021 05:10:57 PM EDT -->
30+
31+
<!--te-->
32+
33+
```python
1934

20-
import cutde
21-
import numpy as np
2235
import matplotlib.pyplot as plt
36+
import numpy as np
37+
38+
import cutde
2339

2440
xs = np.linspace(-2, 2, 200)
2541
ys = np.linspace(-2, 2, 200)
@@ -43,15 +59,15 @@ plt.contour(
4359
obsx, obsy, disp[:, :, 0], colors="k", linestyles="-", linewidths=0.5, levels=21
4460
)
4561
plt.colorbar(cntf)
46-
plt.title(f"$u_x$")
62+
plt.title("$u_x$")
4763
plt.tight_layout()
4864
plt.savefig("docs/example.png", bbox_inches="tight")
49-
}
65+
5066
```
5167

5268
![docs/example.png](docs/example.png)
5369

54-
### Usage documentation
70+
# Usage documentation
5571

5672
Usage is really simple:
5773

@@ -72,7 +88,7 @@ IMPORTANT: N should be the same for all these arrays. There is exactly one trian
7288
* The output `disp` is a `(N, 3)` array with displacement components in the x, y, z directions.
7389
* The output `strain` is a `(N, 6)` array representing a symmetric tensor. `strain[:,0]` is the xx component of strain, 1 is yy, 2 is zz, 3 is xy, 4 is xz, and 5 is yz.
7490

75-
### I want stress.
91+
## I want stress.
7692

7793
Use:
7894

@@ -82,7 +98,7 @@ stress = cutde.strain_to_stress(strain, sm, nu)
8298

8399
to convert from stress to strain assuming isotropic linear elasticity. `sm` is the shear modulus and `nu` is the Poisson ratio.
84100

85-
### All pairs
101+
## All pairs
86102

87103
If, instead, you want to create a matrix representing the interaction between every observation point and every source triangle, there is a different interface:
88104

@@ -102,55 +118,58 @@ strain = cutde.strain_all_pairs(pts, tris, slips, nu)
102118

103119
Note that to use the `strain_to_stress` function, you'll need to reshape the output strain to be `(N_OBS_PTS * N_SRC_TRIS, 6)`.
104120

105-
### Installation
121+
# Installation
106122

107123
To install `cutde` itself run:
108124
```
109125
pip install cutde
110126
```
111127

112-
Next, make sure you are using `conda-forge` with:
113-
```
114-
conda config --prepend channels conda-forge
115-
```
116-
117128
Then, install either PyCUDA or PyOpenCL following the directions below.
118129

119-
**PyCUDA** If you have an NVIDIA GPU, install PyCUDA with:
130+
## PyCUDA
131+
If you have an NVIDIA GPU, install PyCUDA with:
120132
```
133+
conda config --prepend channels conda-forge
121134
conda install -c conda-forge pycuda
122135
```
123136

124-
**PyOpenCL on Mac OS X** Install PyOpenCL and the PoCL OpenCL driver with:
137+
## Mac OS X
138+
Install PyOpenCL and the PoCL OpenCL driver with:
125139
```
140+
conda config --prepend channels conda-forge
126141
conda install pocl pyopencl
127142
```
128143

129-
**PyOpenCL on Ubuntu with PoCL** Just like on a Mac:
144+
## Ubuntu + PyOpenCL/PoCL
145+
146+
Just like on a Mac:
130147
```
148+
conda config --prepend channels conda-forge
131149
conda install pocl pyopencl
132150
```
133151

134-
**PyOpenCL on Ubuntu with system drivers**
152+
153+
## Ubuntu + PyOpenCL with system drivers**
135154
```
136155
conda install pyopencl ocl-icd ocl-icd-system
137156
```
138157
You will need to install the system OpenCL drivers yourself depending on the hardware you have. See the "Something else" section below.
139158

140-
**Windows** I'm not aware of anyone testing cutde on Windows yet. It should not be difficult to install. I would expect that you install pyopencl via conda and then install the OpenCL libraries and drivers that are provided by your hardware vendor. See the "Something else" section below.
141-
```
142-
conda install pyopencl
143-
```
159+
## Windows
160+
161+
I'm not aware of anyone testing cutde on Windows yet. It should not be difficult to install. I would expect that you install pyopencl via conda and then install the OpenCL libraries and drivers that are provided by your hardware vendor. See the "Something else" section below.
144162

145-
**Something else** I'd suggest starting by trying the instructions for the system most similar to yours above. If that doesn't work, never fear! OpenCL should be installable on almost all recent hardware and typical operating systems. [These directions can be helpful.](https://documen.tician.de/pyopencl/misc.html#installing-from-conda-forge). I am happy to try to help if you have OpenCL installation issues, but I can't promise to be useful.
163+
## Something else
164+
I'd suggest starting by trying the instructions for the system most similar to yours above. If that doesn't work, never fear! OpenCL should be installable on almost all recent hardware and typical operating systems. [These directions can be helpful.](https://documen.tician.de/pyopencl/misc.html#installing-from-conda-forge). I am happy to try to help if you have OpenCL installation issues, but I can't promise to be useful.
146165

147-
### Why can't I use Apple CPU OpenCL?
166+
## Why can't I use Apple CPU OpenCL?
148167

149168
You might have gotten the message: `cutde does not support the Apple CPU OpenCL implementation and no other platform or device was found. Please consult the cutde README.`
150169

151170
The Apple OpenCL implementation for Intel CPUs has very poor support for the OpenCL standard and causes lots of difficult-to-resolve errors. Instead, please use [the PoCL implementation](http://portablecl.org/). You can install it with `conda install -c conda-forge pocl`.
152171

153-
### Development
172+
# Development
154173

155174
For developing `cutde`, clone the repo and set up your conda environment based on the `environment.yml` with:
156175

docs/README-tmpl.md

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
# cutde
2-
31
<p align=center>
42
<a target="_blank" href="https://www.python.org/downloads/" title="Python version"><img src="https://img.shields.io/badge/python-%3E=_3.6-green.svg"></a>
53
<a target="_blank" href="https://pypi.org/project/cutde/" title="PyPI version"><img src="https://img.shields.io/pypi/v/cutde?logo=pypi"></a>
64
<!-- <a target="_blank" href="https://pypi.org/project/cutde/" title="PyPI"><img src="https://img.shields.io/pypi/dm/cutde"></a> -->
75
<a target="_blank" href="LICENSE" title="License: MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
6+
<a target="_blank" href="https://github.com/tbenthompson/cutde/actions" title="Test Status"><img src="https://github.com/tbenthompson/cutde/actions/workflows/test.yml/badge.svg"></a>
87
</a>
98

109
# Python + CUDA TDEs from Nikkhoo and Walter 2015
1110

12-
CUDA and OpenCL-enabled fullspace triangle dislocation elements. Benchmarked at 130 million TDEs per second. Based on the [original MATLAB code from Nikhoo and Walter 2015.](https://volcanodeformation.com/software).
11+
CUDA and OpenCL-enabled fullspace triangle dislocation elements. Benchmarked at 130 million TDEs per second. Based on the [original MATLAB code from Nikhoo and Walter 2015.](https://volcanodeformation.com/software)
1312

1413
See below for usage and installation instructions.
1514

16-
### An example
15+
<!--ts-->
16+
<!--te-->
1717

18-
```
18+
```python
1919
<%
2020
with open('docs/example.py', 'r') as f:
2121
example_contents = f.read()
2222
%>
23-
${example_contents}}
23+
${example_contents}
2424
```
2525

2626
![docs/example.png](docs/example.png)
2727

28-
### Usage documentation
28+
# Usage documentation
2929

3030
Usage is really simple:
3131

@@ -46,7 +46,7 @@ IMPORTANT: N should be the same for all these arrays. There is exactly one trian
4646
* The output `disp` is a `(N, 3)` array with displacement components in the x, y, z directions.
4747
* The output `strain` is a `(N, 6)` array representing a symmetric tensor. `strain[:,0]` is the xx component of strain, 1 is yy, 2 is zz, 3 is xy, 4 is xz, and 5 is yz.
4848

49-
### I want stress.
49+
## I want stress.
5050

5151
Use:
5252

@@ -56,7 +56,7 @@ stress = cutde.strain_to_stress(strain, sm, nu)
5656

5757
to convert from stress to strain assuming isotropic linear elasticity. `sm` is the shear modulus and `nu` is the Poisson ratio.
5858

59-
### All pairs
59+
## All pairs
6060

6161
If, instead, you want to create a matrix representing the interaction between every observation point and every source triangle, there is a different interface:
6262

@@ -76,55 +76,58 @@ strain = cutde.strain_all_pairs(pts, tris, slips, nu)
7676

7777
Note that to use the `strain_to_stress` function, you'll need to reshape the output strain to be `(N_OBS_PTS * N_SRC_TRIS, 6)`.
7878

79-
### Installation
79+
# Installation
8080

8181
To install `cutde` itself run:
8282
```
8383
pip install cutde
8484
```
8585

86-
Next, make sure you are using `conda-forge` with:
87-
```
88-
conda config --prepend channels conda-forge
89-
```
90-
9186
Then, install either PyCUDA or PyOpenCL following the directions below.
9287

93-
**PyCUDA** If you have an NVIDIA GPU, install PyCUDA with:
88+
## PyCUDA
89+
If you have an NVIDIA GPU, install PyCUDA with:
9490
```
91+
conda config --prepend channels conda-forge
9592
conda install -c conda-forge pycuda
9693
```
9794

98-
**PyOpenCL on Mac OS X** Install PyOpenCL and the PoCL OpenCL driver with:
95+
## Mac OS X
96+
Install PyOpenCL and the PoCL OpenCL driver with:
9997
```
98+
conda config --prepend channels conda-forge
10099
conda install pocl pyopencl
101100
```
102101

103-
**PyOpenCL on Ubuntu with PoCL** Just like on a Mac:
102+
## Ubuntu + PyOpenCL/PoCL
103+
104+
Just like on a Mac:
104105
```
106+
conda config --prepend channels conda-forge
105107
conda install pocl pyopencl
106108
```
107109

108-
**PyOpenCL on Ubuntu with system drivers**
110+
111+
## Ubuntu + PyOpenCL with system drivers**
109112
```
110113
conda install pyopencl ocl-icd ocl-icd-system
111114
```
112115
You will need to install the system OpenCL drivers yourself depending on the hardware you have. See the "Something else" section below.
113116

114-
**Windows** I'm not aware of anyone testing cutde on Windows yet. It should not be difficult to install. I would expect that you install pyopencl via conda and then install the OpenCL libraries and drivers that are provided by your hardware vendor. See the "Something else" section below.
115-
```
116-
conda install pyopencl
117-
```
117+
## Windows
118+
119+
I'm not aware of anyone testing cutde on Windows yet. It should not be difficult to install. I would expect that you install pyopencl via conda and then install the OpenCL libraries and drivers that are provided by your hardware vendor. See the "Something else" section below.
118120

119-
**Something else** I'd suggest starting by trying the instructions for the system most similar to yours above. If that doesn't work, never fear! OpenCL should be installable on almost all recent hardware and typical operating systems. [These directions can be helpful.](https://documen.tician.de/pyopencl/misc.html#installing-from-conda-forge). I am happy to try to help if you have OpenCL installation issues, but I can't promise to be useful.
121+
## Something else
122+
I'd suggest starting by trying the instructions for the system most similar to yours above. If that doesn't work, never fear! OpenCL should be installable on almost all recent hardware and typical operating systems. [These directions can be helpful.](https://documen.tician.de/pyopencl/misc.html#installing-from-conda-forge). I am happy to try to help if you have OpenCL installation issues, but I can't promise to be useful.
120123

121-
### Why can't I use Apple CPU OpenCL?
124+
## Why can't I use Apple CPU OpenCL?
122125

123126
You might have gotten the message: `cutde does not support the Apple CPU OpenCL implementation and no other platform or device was found. Please consult the cutde README.`
124127

125128
The Apple OpenCL implementation for Intel CPUs has very poor support for the OpenCL standard and causes lots of difficult-to-resolve errors. Instead, please use [the PoCL implementation](http://portablecl.org/). You can install it with `conda install -c conda-forge pocl`.
126129

127-
### Development
130+
# Development
128131

129132
For developing `cutde`, clone the repo and set up your conda environment based on the `environment.yml` with:
130133

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/bash
22
python docs/example.py
33
python docs/tmpl_readme.py
4+
gh-md-toc --insert --no-backup README.md

0 commit comments

Comments
 (0)