Skip to content

Commit

Permalink
Merge branch 'develop' into update_dfn_comparison_examples
Browse files Browse the repository at this point in the history
Conflicts:
	examples/papers/dfn_comparison/example_1_data.py
	examples/papers/dfn_comparison/example_1_vem.py
	examples/papers/dfn_comparison/example_2_1_tpfa.py
	examples/papers/dfn_comparison/example_2_1_vem.py
	examples/papers/dfn_comparison/example_2_1_vem_coarse.py
	src/porepy/fracs/non_conforming.py
	src/porepy/numerics/fv/mpfa.py
  • Loading branch information
alessiofumagalli committed Mar 12, 2018
2 parents 3bd0975 + 3e17191 commit cdc8799
Show file tree
Hide file tree
Showing 178 changed files with 12,036 additions and 4,365 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
sudo: true

language: python

cache: pip
Expand All @@ -7,6 +9,15 @@ python:
- "3.5"
- "3.6"

matrix:
include:
- os: linux
- python: '3.5'
- python: '3.6'

allow_failures:
- python: '2.7'

before install:
- chmod +x ./test/regression/run_cron_test.sh

Expand Down
36 changes: 36 additions & 0 deletions Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Docker Advanced

To facilitate the devoloping, using the text editor,version control and other tools already installed on your computers,
it is possible to share files from the host into the container:

```bash
> docker run -ti -v $(pwd):/home/porepy/shared pmgbergen/porepylib:py27
```
To allow the X11 forwarding in the container, on Linux system just run:

```bash
> docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $(pwd):/home/porepy/shared pmgbergen/porepylib:py27
```
It is also available a docker container based on python 3.6, just running:
```bash
> docker run -ti docker.io/pmgbergen/porepylib:py36
```
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.

# For Developing/ enhance Docker
If you would like to compile Docker for developing porpose. You could associate this github repo with docker cloud service for deployment. Alternatively, on you own machine on terminal (Linux) or on Docker terminal (Mac/Win) you just run:
```bash
> cd dockerfiles/py36 && docker build . --tag porepy:develop
```
The tag of your container will be "porepy" and the version "develop".
# Q&A
To clean the possible cache created by docker you just run:
```bash
> docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)"
```
This command will stop all running container and remove them from your cache. When you exit from the container you need carelly to write exit in terminal in place of close by brute force the terminal.
The following command allow you delete all orphan image that you have create.
```bash
> docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")"
```
26 changes: 16 additions & 10 deletions Install.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# Setting up a PorePy environment
All developers use the conda distribution of python, and we recommend that conda functionality is applied whenever possible.

Installation of PorePy itself should be straightforward, using pip.
In practice, installing from source is the preferred option to get the newest version of the code.
In practice, installing from source is the preferred option to get the newest version of the code - the code hosted on pypi is not always up to date.

To get the code fully working requires a few more steps, as described below.
We also strongly recommend using a virtual environment for your PorePy install.

## Installation on Linux
Instructions are found on the GitHub webpage. Simply type `pip install porepy`.
Instructions are found on the GitHub webpage. The best option is to download the source code from github, and install by `pip install porepy`.

## Intall on Windows
This is a bit more tricky, since installing the dependencies (e.g. `numpy`, `scipy`) using pip requires access to a compiler.
The recommended solution (for working with Python on Windows in general, it seems)
is to install the dependencies using `conda`, and then `pip install porepy`.
We plan to provide conda install for PorePy as well, but have not come that far yet.
is to install the dependencies using `conda`, and then `pip install porepy`, preferrably installing from source.
Most likely, parts of PorePy will not work on Windows due to missing libraries etc. This is not fully clear.

## Docker
There is also a third-party option using Docker containers. For now this should be considered an experimental option.

## How about Mac?
Frankly, we are not sure. None of the devopers use Mac, so testing this has not been a priority.
Expand All @@ -24,20 +28,22 @@ To make this work, you need gmsh installed on your system, and PorePy needs to k
First, visit the [Gmsh webpage](http://gmsh.info) and download a suitable version.
Extract, and move the binary (probably located in the subfolder gmsh-x.x.x-Linux/bin or similar) to whereever you prefer.

NOTE: We have experienced that some fracture geometries are best handled by somewhat older versions of Gmsh (2.11 seems to be a good version) - newer versions are often result in error messages. Until this is resolved, we therefore recommend to use Gmsh 2.11 with PorePy.
NOTE: For complex fracture geometries, our experience is that Gmsh sometimes fails, but the result may depend on which gmsh version is applied. To cope with this, we have ended up switching between Gmsh versions when relevant, always trying to apply an as updated version as possible. The situation is not ideal, but for now this appears to be the best option.

Note to Linux users: Although Gmsh is available through the standard packaging tools, it tends to be hopelessly outdated,
and resulted in severe issues for the fracture meshing last time we checked. Use the GMSH web page instead.


The location of the gmsh file is specific for each user's setup, and is therefore not included in the library.
Instead, to get the path to the gmsh executable, PorePy assumes there is a file called `porepy_config.py` somewhere in `$PYTHONPATH`.
So, open a file called `porepy_config.py`, and place the line

config = {'gmsh_path': 'path/to/where/you/put/the/gmsh/executable/'}

```python
config = {'gmsh_path': 'path/to/gmsh/executable'} # example config = {'gmsh_path': '/usr/bin/gmsh'}
```
Note that the path should be set as a string. To read more about the config system, see `porepy.utils.read_config.py`.

# Other packages
Others libraries that should be installed are numpy (available on both conda and pip), scipy (conda and pip), networkx (conda and pip, NOTE: version number 1.10, NOT 2 - will be updated), meshio (pip only), sympy (conda and pip). In addition libraries like cython, numba, vtk, pymetis and pyamg should be installed to get full functionality.

# Fast unique arrays
Improvements in Numpy's unique function, introduced in numpy version 1.13, can in certain cases speed up PorePy's performance immensely
(we have observed runtimes dropping by orders of magnitude, which of course also shows that the homebrewed code used when numpy is too old is less than optimal).
Expand Down
39 changes: 35 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ PorePy currently has the following distinguishing features:
PorePy is developed by the [Porous Media Group](http://pmg.b.uib.no/) at the University of Bergen, Norway. The software is developed under projects funded by the Reserach Council of Norway and Statoil.

# Reproduce results from papers and preprints
Runscripts for most, if not all, papers that uses porepy is available at [here](https://github.com/pmgbergen/porepy/tree/develop/examples/papers).
Runscripts for most, if not all, papers that uses porepy is available at [here](https://github.com/pmgbergen/porepy/tree/develop/examples/papers).
Note that you may have to revert to an older version of PorePy to run the examples (we try to keep the runscripts updated, but sometime fail to do so, for various reasons).

# Citing
If you use PorePy in your research, we ask you to cite the following publication

E. Keilegavlen, A. Fumagalli, R. Berge, I. Stefansson, I. Berre: PorePy: An Open-Source Simulation Tool for Flow and Transport in Deformable Fractured Rocks. [arXiv:1712.00460](https://arxiv.org/abs/1712.00460)

# Installation
PorePy depends on `numpy`, `scipy` and `networkx`, and (for the moment) also on `meshio`, `sympy` and `matplotlib`. The latter packages may be droped / changed later. To install (on Linux, probably also OSX), use
Expand All @@ -19,7 +25,8 @@ PorePy depends on `numpy`, `scipy` and `networkx`, and (for the moment) also on

We recommend installing from source (see below), rather than pulling from pypi. Installation by pip on Windows may cause problems with buliding the requirements (`numpy` etc) unless conda is used.

For more detailed install instructions, including how to access GMSH (for meshing), see [Install](https://github.com/pmgbergen/porepy/blob/develop/LICENSE.md) .
For more detailed install instructions, including how to access GMSH (for meshing), see
[Install](https://github.com/pmgbergen/porepy/blob/develop/Install.md).

PorePy is developed under Python 3. It should also be compatible with Python 2.7, however, apart from unit testing, it is not being used with Python 2, so be cautious.

Expand All @@ -31,18 +38,39 @@ To get the most current version, install from github:
cd porepy

pip install -r requirements.txt

Finally to install PorePy

pip install .

or for editable installs into the user directory:

pip install --user -e .


# Using Docker
A docker image is available, courtesy of Davide Baroli. To pull the docker.io/pmgbergen/porepylib with tag py27 image from cloud infrastructure:
```bash
> docker pull docker.io/pmgbergen/porepylib:py27
```
Docker will pull the py27 tag of the image pmgbergen/porepylib from docker.io based on python 2.7. The download is around 4.085 GB. The image is a great place to start experimenting with porepy and includes all dependencies already compiled for you.
Once the download is complete you can start porepy for the first time. Just run:
```bash
> docker run -ti docker.io/pmgbergen/porepy:py27
```
The image is auto-deployed at each push in the branch "develop".

For more details see the [docker md](./Docker.md).

# (Semi-) Optional packages
To function optimally, PorePy should have access to the pypi packages:
* `pymetis` (for mesh partitioning). Will be installed on Linux (not so on Windows, to avoid installation issues for the core package in the case where no C compiler is available).
* Some computationally expensive methods can be accelerated with `Cython` or `Numba`. Cython is automatically installed on many Linux systems, if not, use pip or conda. Numba can be installed using `conda`.
* Visualization by either matplotlib or (preferrable for larger problems) vtk/paraview. To dump data to paraview, a vtk filter must be available; the only solution we have found is from the 'conda' repositories, e.g. 'conda install -c clinicalgraphics vtk=7.1.0' (note that vtk should be version 7.0.0 or later, hence not the official channel)
* Meshing: currently by [gmsh](http://gmsh.info/doc/texinfo/gmsh.html) .
* Meshing: currently by [gmsh](http://gmsh.info/doc/texinfo/gmsh.html). For its configuration see [Install](https://github.com/pmgbergen/porepy/blob/develop/Install.md).

# Testing
To test build locally
To test build locally, the second command requires gmsh (see [Install](https://github.com/pmgbergen/porepy/blob/develop/Install.md))

pip install -r requirements-dev.txt

Expand All @@ -54,4 +82,7 @@ Confer the [tutorials](https://github.com/pmgbergen/porepy/tree/develop/tutorial
# Problems
Create an [issue](https://github.com/pmgbergen/porepy/issues)

# License
See [license md](./LICENSE.md).


41 changes: 41 additions & 0 deletions dockerfiles/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM phusion/baseimage:0.9.22
MAINTAINER dbaroli <davide.baroli@uni.lu>
# Get Ubuntu updates
USER root
RUN apt-get update && \
apt-get upgrade -y -o Dpkg::Options::="--force-confold" && \
apt-get -y install locales sudo && \
echo "C.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Set locale environment
ENV LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
LANGUAGE=C.UTF-8

COPY set-home-permission.sh /etc/my_init.d/set-home-permission.sh
RUN useradd -m -s /bin/bash -G sudo,docker_env porepy && \
echo "porepy:docker" | chpasswd && \
echo "porepy ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
touch /etc/service/syslog-forwarder/down && \
echo "cat /home/porepy/WELCOME" >> /home/porepy/.bashrc && \
chmod +x /etc/my_init.d/set-home-permission.sh && \
ldconfig
RUN echo "/usr/local/lib/python3/dist-packages" >> /usr/local/lib/python3.5/dist-packages/debian-ubuntu-sitepath-fix.pth
RUN touch /etc/service/syslog-forwarder/down

USER porepy
ENV POREPY_HOME /home/porepy
RUN touch $POREPY_HOME/.sudo_as_admin_successful && \
mkdir $POREPY_HOME/shared
VOLUME /home/porepy/shared

# Print something nice on entry.
COPY WELCOME $POREPY_HOME/WELCOME

WORKDIR /home/porepy
USER root
ENTRYPOINT ["sudo","/sbin/my_init","--quiet","--","sudo","-u","porepy","/bin/bash","-l","-c"]
CMD ["/bin/bash","-i"]

4 changes: 4 additions & 0 deletions dockerfiles/base/WELCOME
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# porepy project base image

You are seeing this message because the Dockerfile you
are using did not add its own WELCOME message to the container.
15 changes: 15 additions & 0 deletions dockerfiles/base/set-home-permission.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# User can pass e.g. --env HOST_UID=1003 so that UID in the container matches
# with the UID on the host. This is useful for Linux users, Mac and Windows
# already do transparent mapping of shared volumes.
if [ "$HOST_UID" ]; then
usermod -u $HOST_UID porepy
fi
if [ "$HOST_GID" ]; then
groupmod -g $HOST_GID porepy
fi
# This makes sure that all files in /home/porepy are accessible by the user
# fenics. We exclude the folder ~/shared to reduce IO out to the host. Docker
# for Mac, Docker for Windows and the UID/GID trick above should mean that file
# permissions work seamlessly now.
find /home/porepy -maxdepth 1 | sed "1d" | grep -v "/home/porepy/shared" | xargs chown -R porepy:porepy 2> /dev/null || true
86 changes: 86 additions & 0 deletions dockerfiles/py27-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
FROM docker.io/pmgbergen/porepylib:base
MAINTAINER dbaroli <davide.baroli@uni.lu>

USER root

RUN apt-get -qq update && \
apt-get -y --with-new-pkgs \
-o Dpkg::Options::="--force-confold" upgrade && \
apt-get -y install curl && \
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \
apt-get update -y; apt-get install -y --force-yes --fix-missing --no-install-recommends curl git git-lfs unzip tree subversion vim cmake bison g++ gfortran openmpi-bin pkg-config wget \
libpcre3-dev bison flex swig libglu1-mesa libxcursor-dev libxft-dev libxinerama-dev libmed1v5 libpng12-0 liboce-foundation10 liboce-modeling10 pyqt5-dev-tools bash-completion libxt6 &&\
git lfs install && \
apt-get clean && \
git lfs install && \
ln -s /usr/lib/x86_64-linux-gnu/libGLU.so.1 /usr/lib/libGLU.so.1 &&\
ln -s /usr/lib/x86_64-linux-gnu/libSM.so.6 /usr/lib/libSM.so.6 && \
ln -s /usr/lib/x86_64-linux-gnu/libICE.so.6 /usr/lib/libICE.so.6 && \
ln -s /usr/lib/x86_64-linux-gnu/libX11.so.6 /usr/lib/libX11.so.6 && \
ln -s /usr/lib/x86_64-linux-gnu/libXext.so.6 /usr/lib/libXext.so.6 && \
ln -s /usr/lib/x86_64-linux-gnu/libXt.so.6 /usr/lib/libXt.so.6 && \
ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so.1 &&\
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*


WORKDIR /tmp

ENV GMSH_VERSION 2.11.0
RUN wget http://gmsh.info/bin/Linux/gmsh-${GMSH_VERSION}-Linux64.tgz &&\
tar xf gmsh-${GMSH_VERSION}-Linux64.tgz && \
cp gmsh-${GMSH_VERSION}-Linux/bin/gmsh /usr/local/bin/gmsh && \
rm -rf /tmp/*

RUN cd /tmp && \
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O conda.sh && \
chmod +x conda.sh && \
bash conda.sh -b -p /home/porepy/.conda && \
rm /tmp/*

RUN id porepy
RUN chown -R porepy:porepy /home

USER porepy

ENV PATH=/home/porepy/.conda/bin:$PATH


RUN echo "PATH=/home/porepy/.conda/bin:$PATH" >> ~/.profile && \
/bin/bash -c -l "source ~/.profile"

RUN hash -r && \
conda config --set always_yes yes --set changeps1 no && \
conda update -q conda && \
conda info -a && \
conda create --yes -n porepy python="2.7"
RUN /bin/bash -c -l "source activate porepy"
ENV PATH /home/porepy/.conda/envs/porepy/bin:$PATH
ENV CONDA_DEFAULT_ENV porepy
ENV CONDA_PREFIX /home/porepy/.conda/envs/porepy


RUN conda install --yes numpy scipy matplotlib pip nose sip &&\
conda install -c https://conda.anaconda.org/clinicalgraphics vtk &&\
pip install setuptools && \
pip install enum34 && \
pip install numpy-stl && \
pip install coveralls && \
pip install coverage &&\
pip install numba cython &&\
pip install jupyter ipython pdbpp


WORKDIR $POREPY_HOME
RUN mkdir -p $POREPY_HOME/.config/matplotlib
COPY matplotlibsrc $POROPY_HOME/.config/matplotlib/matplotlibrc


COPY dependencies $POROPY_HOME/.dependencies
RUN pip install --no-cache-dir -r $POROPY_HOME/.dependencies
RUN /bin/bash -c -l "echo 'source activate porepy'>>~/.profile" && \
/bin/bash -c -l "echo 'PYTHONPATH=/home/porepy/conda/envs/porepy/lib/python2.7/site-packages:$PYTHONPATH'>>~/.profile"
COPY install $POREPY_HOME
RUN sudo chmod +x install



14 changes: 14 additions & 0 deletions dockerfiles/py27-dev/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
meshio == 1.10
networkx == 1.10
numpy >= 1.10
scipy >= 0.17
sympy >= 1.0
matplotlib >= 1.0
pymetis >= 2016.2;platform_system=="Linux"
cython >= 0.23;platform_system=="Linux"
pytest >= 3.0.0
pytest-cov
pytest-runner >= 2.0
coverage
coveralls
six
Loading

0 comments on commit cdc8799

Please sign in to comment.