Skip to content

Commit 7d22c48

Browse files
committed
More documentation and moved python app to another repo
1 parent c1798c8 commit 7d22c48

26 files changed

Lines changed: 370 additions & 3139 deletions

.github/workflows/tests.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
name: 'Tests'
3+
4+
on:
5+
push:
6+
7+
pull_request:
8+
types: [opened, synchronize] #labeled, assigned]
9+
10+
jobs:
11+
build-and-test:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: [3.7, 3.8] # 2.7,
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@main
19+
with:
20+
submodules: recursive
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
29+
- name: Test with pytest
30+
run: |
31+
pip install -e .
32+
python -m unittest discover -v

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

Makefile

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,49 +12,20 @@ endif
1212

1313
all: test
1414

15-
16-
# --- Rules for python app
17-
test:
18-
python viz3danim.py
19-
20-
21-
tests:
22-
python -m unittest discover -v
23-
24-
dep:
25-
python -m pip install -r requirements.txt
26-
27-
install:
28-
python setup.py install
29-
30-
installer:
31-
python -m nsist installer.cfg
32-
33-
34-
# --- Rules for web app
3515
sd2viz:
36-
python subDynModeViz.py --open examples/OC4_Jacket.sum.yaml
37-
# python subDynModeViz.py --open examples/Main_Monopile-SoilDyn-Simple.SD.sum.yaml
38-
# python subDynModeViz.py --open examples/TetraSpar.SD.sum.yaml
39-
# python subDynModeViz.py --open examples/Main_Spar.SD.sum.yaml
40-
# python subDynModeViz.py --open examples/Pendulum.SD.sum.yaml
16+
python legacy/subDynModeViz.py --open examples/OC4_Jacket.sum.yaml
4117

4218
sd2json:
43-
python subDynModeViz.py examples/TetraSpar.SD.sum.yaml
44-
python subDynModeViz.py examples/Main_Monopile_Decay.SD.sum.yaml
45-
python subDynModeViz.py examples/Main_OC4_Jacket_Decay.SD.sum.yaml
46-
python subDynModeViz.py examples/Main_Spar.SD.sum.yaml
47-
python subDynModeViz.py examples/Pendulum.SD.sum.yaml
19+
python legacy/subDynModeViz.py examples/TetraSpar.SD.sum.yaml
20+
python legacy/subDynModeViz.py examples/Main_Monopile_Decay.SD.sum.yaml
21+
python legacy/subDynModeViz.py examples/Main_OC4_Jacket_Decay.SD.sum.yaml
22+
python legacy/subDynModeViz.py examples/Main_Spar.SD.sum.yaml
23+
python legacy/subDynModeViz.py examples/Pendulum.SD.sum.yaml
4824

4925
server:
50-
python subDynModeViz.py --open
51-
#python -m http.server 8080
26+
python webapp.py
5227

5328

54-
# --- Common rules
5529
clean:
5630
rm -rf __pycache__
5731
rm -rf *.egg-info
58-
rm -rf *.spec
59-
rm -rf build*
60-
rm -rf dist

README.md

Lines changed: 92 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,106 @@
1+
[![Build status](https://github.com/ebranlard/viz3danim/workflows/Tests/badge.svg)](https://github.com/ebranlard/viz3danim/actions?query=workflow%3A%22Tests%22)
2+
<a href="https://www.buymeacoffee.com/hTpOQGl" rel="nofollow"><img alt="Donate just a small amount, buy me a coffee!" src="https://warehouse-camo.cmh1.psfhosted.org/1c939ba1227996b87bb03cf029c14821eab9ad91/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d4275792532306d6525323061253230636f666665652d79656c6c6f77677265656e2e737667"></a>
13
# viz3Danim
24

3-
Visualize 3D structures, mode shapes and animations.
5+
Interactive visualization of 3D structures, mode shapes and animations, using a json file format (described [here](json-file-format)).
46

5-
Two different applications are provided:
67

7-
- a web browser app (.json files), see the active version [with an example](https://ebranlard.github.io/viz3Danim/index.html?load=examples/OC4_Jacket_All.sum.json) or [without](https://ebranlard.github.io/viz3Danim/)
8+
[![Demo](/../main/ressources/figs/demo.gif)](https://ebranlard.github.io/viz3Danim/index.html?load=examples/OC4_Jacket_All.sum.json)
89

9-
- a python app (.dat, .yaml), in beta
1010

11+
This program is a "web app", meaning that it can run in a web browser, with no installation needed.
12+
The app can be run without internet on your local machine (provided you have python installed).
1113

12-
See documentation below for the Python app and Web App.
13-
14+
For convenience, we provide a live and active version hosted on github.io, [with an example](https://ebranlard.github.io/viz3Danim/index.html?load=examples/OC4_Jacket_All.sum.json) or [without example](https://ebranlard.github.io/viz3Danim/).
1415

16+
NOTE: no files are stored on the server, no cookies are used, everything is run on the client side. It should be safe to use confidential files on this live version. For increased privacy, see [how to run the Web App locally](#running-the-web-app-locally).
1517

18+
A python app is in development [here](https://github.com/ebranlard/pyviz3danim) but is still in "beta".
1619

1720

1821
## Json file format
19-
The input files are `.json` files. The content of the file is faily simple: list of nodes, connectivity matrix defining elements, and nodal displacements for each modes/time series.
20-
The format is undocumented for now, as it might evolve in the future.
21-
Example files are located in the `examples` folder of this repository.
22+
The input files are `.json` files. You can see [a simple example](#a-simple-example-of-json-file) below, and more advanced examples in the [examples](/examples/) directory of this repository.
2223

24+
The content of the file is as follows:
2325

24-
The `json` files can be generated using:
26+
- `Nodes`: a list of nodal coordinates (x,y,z) for each node
27+
- `Connectivity`: a connectivity matrix providing the node indices defining each element (for now elements consists of two nodes)
28+
- `ElemeProps`: properties for each element
29+
- `Modes`: optional field providing the modes of the structure.
30+
- `TimeSeries`: optional field providing the time series of displacements of the structure.
31+
The format is mostly undocumented for now, it might evolve in the future.
32+
Example files are located in the `examples` folder of this repository.
33+
34+
The `.json` files can be generated using:
2535

2636
- SubDyn (part of [OpenFAST](https://github.com/openfast/openfast)). Setting the options `OutCBModes` and `OutFEMModes`, see [here](https://openfast.readthedocs.io/en/dev/source/user/subdyn/input_files.html#output-summary-and-outfile).
2737

28-
- The python module `graph.py` and finite element (FEM) module of [welib](https://github.com/ebranlard/welib). See [examples](https://github.com/ebranlard/welib/tree/dev/welib/FEM/examples).
38+
- The python module `graph.py` and finite element (FEM) module of [welib](https://github.com/ebranlard/welib). See the [welib FEM examples](https://github.com/ebranlard/welib/tree/dev/welib/FEM/examples).
39+
40+
41+
### A simple example of Json file:
42+
43+
Below is an example of json file where a triangle, made of three nodes and three elements.
44+
Two "modes" are included, where the base of the triangle moves rigidly along the x or y direction.
45+
```json
46+
{"Connectivity":[
47+
[0, 1],
48+
[1, 2],
49+
[2, 0]
50+
],
51+
"Nodes": [
52+
[ 0.0, 0.0, 1.0],
53+
[ 0.0,-0.25, 0.0],
54+
[ 0.0, 0.25, 0.0]
55+
],
56+
"ElemProps": [
57+
{"shape": "cylinder", "Diam": 0.1},
58+
{"shape": "cylinder", "Diam": 0.2},
59+
{"shape": "cylinder", "Diam": 0.1}
60+
],
61+
"Modes": {
62+
"defaultSet": [
63+
{"name": "Mode1", "Displ": [[0.0, 0.0, 0.0], [0.3, 0.0, 0.0], [0.3, 0.0, 0.0]]},
64+
{"name": "Mode2", "Displ": [[0.0, 0.0, 0.0], [0.0, 0.3, 0.0], [0.0, 0.3, 0.0]]}
65+
]
66+
}
67+
}
68+
```
69+
Loading this `json` file results in the following 3d visualization (click on the image to visualize the mode in the live version of the web app):
70+
71+
72+
[<img alt="alt_text" width="300px" src="/../main/ressources/figs/triangle.png" />](https://ebranlard.github.io/viz3Danim/index.html?load=examples/triangle.json)
2973

3074

3175

32-
## Web App
76+
## Using the Web App
3377
A live and active version of the web GUI is available [here with an example](https://ebranlard.github.io/viz3Danim/index.html?load=examples/OC4_Jacket_All.sum.json) or [here without an example](https://ebranlard.github.io/viz3Danim/).
3478

79+
You can also launch a local version of the Web App on your machine, without the need for an internet connection. See [how to run the Web App locally](#running-the-web-app-locally).
80+
81+
3582
### Basic help
3683

37-
- To open a file in the Web App, simply dragging and drop a `json` file into your browser.
84+
- To open a file in the Web App, simply drag and drop a `json` file into your browser. You can alternatively use the the dropdown menu "Menu > Load"
3885

3986
- For more help, look at "Menu -> Help", in particular for some keyboard shortcuts to scale the modes amplitudes and frequencies.
4087

4188
### Keyboard shortcuts
42-
a: increase amplitude
43-
d: decrease amplitude
44-
w: speed up
45-
s: slow down
89+
a: increase amplitude of modes
90+
d: decrease amplitude of modes
91+
w: speed up modes or animation
92+
s: slow down modes or animation
4693

4794

4895

4996
### Running the Web App locally.
50-
You can run with Web App without internet. Simply clone this repository, install the dependencies (`python -m pip install -r requirements.txt`) and run `make server` from the root of the repository.
51-
This should create a local web server and launch the local version of the web app into your browser.
52-
53-
54-
55-
56-
57-
58-
59-
## Python App (Beta)
60-
61-
The python app can open SubDyn and HydroDyn inputs files (.dat), and SubDyn yaml files (.yaml) to display the modes.
62-
63-
###Installation:
97+
You can run with Web App locally and without internet for convenience and confidentiality is of concern.
98+
Simply clone this repository and from the root of this repository run:
6499
```bash
65-
git clone --recurse-submodules http://github.com/ebranlard/viz3danim
66-
cd viz3danim
67-
python -m pip install -r requirements.txt
100+
python webapp.py
68101
```
69-
70-
If you forgot the `recurse-submodules` flag, and you end up with errors that `weio` is missing, type the following:
71-
```bash
72-
git submodule update --init --recursive
73-
```
74-
75-
###Running:
76-
```bash
77-
python viz3danim.py
78-
```
79-
80-
Drag and drop files.
81-
102+
This should create a local web server and launch the local version of the web app into your browser.
103+
If your browswer does not open automatically, open it, and navigate to `https://localhost:1337/`.
82104

83105

84106

@@ -87,13 +109,11 @@ Drag and drop files.
87109

88110
## SubDyn modes visualization (legacy)
89111

90-
The latest version of SubDyn can generate the '.json' file with Craig-Bampton, Guyan and FEM mode shapes.
91-
Simply drag and drop the `.json` files into the browser.
92-
There is no need to follow the step below.
112+
The latest version of SubDyn (part of [OpenFAST](https://github.com/openfast/openfast)) can generate the '.json' file with Craig-Bampton, Guyan and FEM mode shapes by setting the options `OutCBModes` and `OutFEMModes`, in the SubDyn input file (see [here](https://openfast.readthedocs.io/en/dev/source/user/subdyn/input_files.html#output-summary-and-outfile)). After running SubDyn, simply drag and drop the generated `.json` files into the browser. There is no need to follow the step below which are for older version of SubDyn.
93113

94-
### Generating a json file from a summary file:
114+
### Generating a json file from a SubDyn summary file:
95115
There are two steps for now:
96-
1. Convert the yaml file to a "json" file, using a standalone python script called `subDynModeViz
116+
1. Convert the yaml file to a "json" file, using a standalone python script called `subDynModeViz` located in the `legacy` folder`
97117
2. Load the json file into the web-gui, which requires a web-server (more on that later).
98118
We can make that 1 step in the future if needed.
99119

@@ -105,22 +125,36 @@ The python script and web-app are located in this repository (i.e. [here](https:
105125
### Step 1 (and 2):
106126
- To generate a json file:
107127

108-
python subDynModeViz File.sum.yaml
128+
python legacy/subDynModeViz File.sum.yaml
109129

110130
- To generate a json file, launch a web server and open the json file directly:
111131

112-
python subDynModeViz --open File.sum.yaml
132+
python legacy/subDynModeViz --open File.sum.yaml
113133

114134
### Step 2 :
115135
- Option 1: use the [internet demo version](https://ebranlard.github.io/viz3Danim/) and open the json file there
116136
- Option 2: use the python script with `--open` flag to launch a local server
117137
- Option 3: create your own local server and open the json file manually:
118138
```bash
119-
python -m http.server 8000 # launch a web server
120-
# then open a browser and navigate to https://localhost:8000/
139+
python legacy/subdynModeViz --open # launch a web server on port 1337
140+
# then open a browser and navigate to https://localhost:1337/
121141
```
122142

123-
### Current limitations:
124-
- "json" format undocumented
125143

126144

145+
146+
# Debugging
147+
148+
Most browser can open a debugging console by pressing `Ctrl+Shift+J`. Error messages from javascript will be reported in the Console window, together with some log outputs from the app.
149+
150+
To force reload the webapp use `Ctrl-F5`, this will reload all the files included (otherwise cached versions are used).
151+
152+
153+
154+
# Contributing
155+
Any contributions to this project are welcome! If you want to add a feature to this program or report a bug, the best approach would be to open an issue and start the discussion there.
156+
157+
158+
If you find this project useful, you can also buy me a coffee (donate a small amount) with the link below:
159+
160+
<a href="https://www.buymeacoffee.com/hTpOQGl" rel="nofollow"><img alt="Donate just a small amount, buy me a coffee!" src="https://warehouse-camo.cmh1.psfhosted.org/1c939ba1227996b87bb03cf029c14821eab9ad91/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d4275792532306d6525323061253230636f666665652d79656c6c6f77677265656e2e737667"></a>

0 commit comments

Comments
 (0)