Skip to content

Commit 2e86bc8

Browse files
authored
Merge branch 'master' into version2
2 parents a21a8f5 + 62b2c38 commit 2e86bc8

File tree

9 files changed

+721
-47
lines changed

9 files changed

+721
-47
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ before_install:
2525
# We do this conditionally because it saves us some downloading if the
2626
# version is the same.
2727
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
28-
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
28+
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
2929
else
3030
brew update;
3131
brew install python;
32-
wget https://repo.continuum.io/miniconda/Miniconda2-latest-MacOSX-x86_64.sh -O miniconda.sh;
32+
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh;
3333
fi
3434
- chmod +x miniconda.sh
3535
- bash miniconda.sh -b -p $HOME/miniconda

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<a href="https://www.codacy.com/app/mathLab/PyGeM?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=mathLab/PyGeM&amp;utm_campaign=Badge_Grade" target="_blank">
1717
<img alt="Codacy Badge" src="https://api.codacy.com/project/badge/Grade/7299abd9d61c4aa586903d80cea01c82">
1818
</a>
19+
<a href="https://registry.hub.docker.com/r/sissamathlab/pygem">
20+
<img alt="Docker Pulls" src="https://img.shields.io/docker/pulls/sissamathlab/pygem">
21+
</a>
1922
</p>
2023

2124
[PyGeM](http://mathlab.github.io/PyGeM/) (Python Geometrical Morphing) is a python package that allows you to deform a given geometry or mesh with different deformation techniques such as FFD, RBF and IDW.
@@ -38,7 +41,7 @@
3841
**PyGeM** is a python package using **Free Form Deformation**, **Radial Basis Functions** and **Inverse Distance Weighting** to parametrize and morph complex geometries. It is ideally suited for actual industrial problems, since it allows to handle:
3942

4043
- Computer Aided Design files (in .iges, .step, and .stl formats)
41-
- Mesh files (in .unv and OpenFOAM formats)
44+
- Mesh files (in .unv, Elmer, and OpenFOAM formats)
4245
- Output files (in .vtk format)
4346
- LS-Dyna Keyword files (.k format)
4447

@@ -83,25 +86,25 @@ Docker containers are extremely lightweight, secure, and are based on open stand
8386
Install Docker for your platform by following [these instructions](https://docs.docker.com/engine/getstarted/step_one/).
8487
If using the Docker Toolbox (macOS versions < 10.10 or Windows versions < 10), make sure you run all commands inside the Docker Quickstart Terminal.
8588

86-
Now we will pull the docker.io/pygemdocker/pygem image from our cloud infrastructure:
89+
Now we will pull the sissamathlab/pygem image from our cloud infrastructure:
8790
```bash
88-
> docker pull docker.io/pygemdocker/pygem:latest
91+
> docker pull sissamathlab/pygem:latest
8992
```
9093
Docker will pull the latest tag of the image pygemdocker/pygem from docker.io. The download is around 3.246 GB. The image is a great place to start experimenting with PyGeM and includes all dependencies already compiled for you.
9194
Once the download is complete you can start PyGeM for the first time. Just run:
9295
```bash
93-
> docker run -ti pygemdocker/pygem:latest
96+
> docker run -ti sissamathlab/pygem:latest
9497
```
9598
To facilitate the devoloping, using the text editor,version control and other tools already installed on your computers,
9699
it is possible to share files from the host into the container:
97100

98101
```bash
99-
> docker run -ti -v $(pwd):/home/PyGeM/shared pygemdocker/pygem:latest
102+
> docker run -ti -v $(pwd):/home/PyGeM/shared sissamathlab/pygem:latest
100103
```
101104
To allow the X11 forwarding in the container, on Linux system just run:
102105

103106
```bash
104-
> docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $(pwd):/home/PyGeM/shared pygemdocker/pygem:latest
107+
> docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $(pwd):/home/PyGeM/shared sissamathlab/pygem:latest
105108
```
106109

107110
For Windows system, you need to install Cygwin/X version and running the command in Cygwin terminal. While for mac system, you need to install xquartz.

dockerfiles/Dockerfile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ RUN useradd -m -s /bin/bash -G sudo,docker_env PyGeM && \
2525
echo "PyGeM:docker" | chpasswd && \
2626
echo "PyGeM ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
2727

28-
RUN touch /etc/service/syslog-forwarder/down
29-
COPY set-home-permissions.sh /etc/my_init.d/set-home-permissions.sh
30-
RUN chmod +x /etc/my_init.d/set-home-permissions.sh
3128

3229
USER PyGeM
3330
ENV HOME /home/PyGeM
@@ -50,7 +47,7 @@ RUN id PyGeM
5047
RUN chown -R PyGeM:PyGeM $HOME
5148

5249
RUN cd /tmp && \
53-
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh && \
50+
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \
5451
chmod +x miniconda.sh && \
5552
bash miniconda.sh -b -p /usr/local/miniconda && \
5653
rm /tmp/*
@@ -63,7 +60,7 @@ RUN hash -r && \
6360
conda config --set always_yes yes --set changeps1 no && \
6461
conda update -q conda
6562
RUN conda info -a && \
66-
conda create --yes -n test python="2.7";
63+
conda create --yes -n test python="3.7";
6764

6865
RUN /bin/bash -c 'source activate test'
6966
# The default sip version has api that is not compatible with qt4.
@@ -82,5 +79,3 @@ RUN cd $HOME && \
8279
python setup.py install
8380

8481
USER PyGeM
85-
86-

dockerfiles/set-home-permissions.sh

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

pygem/__init__.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
PyGeM init
33
"""
44
# __all__ = [
5-
# 'affine', 'filehandler', 'freeform', 'radial', 'openfhandler',
5+
# 'affine', 'filehandler', 'freeform', 'radial', 'openfhandler', 'elmerhandler',
66
# 'stlhandler', 'unvhandler', 'vtkhandler', 'nurbshandler', 'stephandler',
77
# 'igeshandler', 'utils', 'gui', 'khandler', 'idw'
88
# ]
@@ -25,17 +25,4 @@ def get_current_year():
2525
from .ffd import FFD
2626
from .rbf import RBF
2727
from .idw import IDW
28-
from .rbf_factory import RBFFactory
29-
30-
"""
31-
"""
32-
#from .radial import RBF
33-
#from .idw import IDW
34-
#from .filehandler import FileHandler
35-
#from .openfhandler import OpenFoamHandler
36-
#from .stlhandler import StlHandler
37-
#from .unvhandler import UnvHandler
38-
#from .vtkhandler import VtkHandler
39-
#from .khandler import KHandler
40-
#from .mdpahandler import MdpaHandler
41-
#from .params import *
28+
from .rbf_factory import RBFFactory

pygem/elmerhandler.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
"""
2+
Derived module from filehandler.py to handle ElmerFEM files.
3+
"""
4+
import numpy as np
5+
import pygem.filehandler as fh
6+
7+
8+
class ElmerHandler(fh.FileHandler):
9+
"""
10+
Elmer mesh file handler class.
11+
12+
:cvar string infile: name of the input file to be processed.
13+
:cvar string outfile: name of the output file where to write in.
14+
:cvar list extensions: extensions of the input/output files. It
15+
is equal to ['.node'] since elmer files do not have extension.
16+
"""
17+
18+
def __init__(self):
19+
super(ElmerHandler, self).__init__()
20+
self.extensions = ['.nodes']
21+
22+
def parse(self, filename):
23+
"""
24+
Method to parse the `filename`. It returns a matrix with all
25+
the coordinates.
26+
27+
:param string filename: name of the input file.
28+
29+
:return: mesh_points: it is a `n_points`-by-3 matrix containing
30+
the coordinates of the points of the mesh
31+
:rtype: numpy.ndarray
32+
33+
.. todo::
34+
35+
- specify when it works
36+
"""
37+
self._check_filename_type(filename)
38+
self._check_extension(filename)
39+
40+
self.infile = filename
41+
42+
i = 0
43+
n_points = 0
44+
with open(self.infile, 'r') as input_file:
45+
for line in input_file:
46+
n_points += 1
47+
mesh_points = np.zeros(shape=(n_points, 3))
48+
49+
with open(self.infile, 'r') as input_file:
50+
51+
i = 0
52+
for line in input_file:
53+
numbers = line.split() #[n1 p x y z] -> [x y z]
54+
del numbers[0:2]
55+
56+
j = 0
57+
for number in numbers:
58+
59+
mesh_points[i][j] = float(number)
60+
j += 1
61+
i += 1
62+
63+
return mesh_points
64+
65+
def write(self, mesh_points, filename):
66+
"""
67+
Writes a elmer file, called filename, copying all the
68+
lines from self.filename but the coordinates. mesh_points
69+
is a matrix that contains the new coordinates to write in
70+
the elmer file.
71+
72+
:param numpy.ndarray mesh_points: it is a `n_points`-by-3
73+
matrix containing the coordinates of the points of the mesh.
74+
:param string filename: name of the output file.
75+
76+
.. todo:: DOCS
77+
"""
78+
self._check_filename_type(filename)
79+
self._check_extension(filename)
80+
self._check_infile_instantiation()
81+
self.outfile = filename
82+
83+
n_points = mesh_points.shape[0]
84+
i = 0
85+
with open(self.infile, 'r') as input_file, open(self.outfile,
86+
'w') as output_file:
87+
for line in input_file:
88+
numbers = line.split() #[n1 p x y z]
89+
90+
output_file.write(numbers[0] + ' ' +numbers[1] + ' ' \
91+
+ str(mesh_points[i][0]) + ' ' + str(mesh_points[i][1]) \
92+
+ ' ' + str(mesh_points[i][2]))
93+
i += 1
94+
95+
if i != n_points:
96+
output_file.write('\n')
97+

0 commit comments

Comments
 (0)