Skip to content

Commit

Permalink
Merge pull request #122 from precice/fenics-adapter-v1.1.0
Browse files Browse the repository at this point in the history
Release v1.1.0
  • Loading branch information
IshaanDesai authored Apr 15, 2021
2 parents bd74827 + 15be563 commit beabcd1
Show file tree
Hide file tree
Showing 20 changed files with 228 additions and 101 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ jobs:
uses: actions/checkout@v2
- name: Install fake precice
run: |
mkdir -p precice
mkdir -p precice
echo "from setuptools import setup" >> precice/setup.py
echo "setup(name='pyprecice', version='2.0.2.1')" >> precice/setup.py
python3 -m pip install ./precice/
- name: Run unit tests
run: python3 setup.py test
run: python3 setup.py test -s tests.unit
- name: Run integration tests
run: python3 setup.py test -s tests.integration
15 changes: 15 additions & 0 deletions .github/workflows/check-pep8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: autopep8
on: push
jobs:
autopep8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: autopep8
id: autopep8
uses: peter-evans/autopep8@v1
with:
args: --recursive --diff --aggressive --aggressive --exit-code --ignore E402 --max-line-length 120 .
- name: Fail if autopep8 made changes
if: ${{ steps.autopep8.outputs.exit-code == 2 }}
run: exit 1
60 changes: 60 additions & 0 deletions .github/workflows/run-tutorials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Run preCICE Tutorials
on:
push:
branches:
- master
- develop
pull_request:
paths:
- '**'

jobs:
run_ht_simple:
name: Run HT, simple
runs-on: ubuntu-latest
container: precice/precice
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install Dependencies & FEniCS
run: |
apt-get -qq update
apt-get -qq install software-properties-common python3-dev python3-pip git apt-utils
add-apt-repository -y ppa:fenics-packages/fenics
apt-get -qq install --no-install-recommends fenics
rm -rf /var/lib/apt/lists/*
- name: Install adapter
run: pip3 install --user .
- name: Fix broken FEniCS installation (see https://fenicsproject.discourse.group/t/installing-python-package-with-fenics-dependency-breaks-fenics-installation/4476)
run: pip3 uninstall -y fenics-ufl
- name: Get tutorials
run: git clone -b develop https://github.com/precice/tutorials.git
- name: Run tutorial
run: |
cd tutorials/partitioned-heat-conduction/fenics
python3 heat.py -d & python3 heat.py -n
run_ht_complex:
name: Run HT, complex
runs-on: ubuntu-latest
container: precice/precice
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install Dependencies & FEniCS
run: |
apt-get -qq update
apt-get -qq install software-properties-common python3-dev python3-pip git apt-utils
add-apt-repository -y ppa:fenics-packages/fenics
apt-get -qq install --no-install-recommends fenics
rm -rf /var/lib/apt/lists/*
- name: Install adapter
run: pip3 install --user .
- name: Fix broken FEniCS installation (see https://fenicsproject.discourse.group/t/installing-python-package-with-fenics-dependency-breaks-fenics-installation/4476)
run: pip3 uninstall -y fenics-ufl
- name: Get tutorials
run: git clone -b develop https://github.com/precice/tutorials.git
- name: Run tutorial
run: |
cd tutorials/partitioned-heat-conduction-complex/fenics
python3 heat.py -d -i complex & python3 heat.py -n -i complex
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
matrix:
matrix:
allow_failures:
- name: "Systemtests [failure allowed]"
include:
- os: linux
name: "Systemtests"
name: "Systemtests [failure allowed]"
if: fork = false AND ( branch = master OR branch = develop )
python: "3.6"
env: PY=python3
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# FEniCS-preCICE adapter changelog

## 1.1.0

* Only warn during initialization, if duplicate boundary point is found for point sources.
* Remove deprecated package `fenicsadapter`. Don't use `import fenicsadapter`. Please use `import fenicsprecice`. https://github.com/precice/fenics-adapter/pull/121

## 1.0.1

* Bugfix for PointSources https://github.com/precice/fenics-adapter/issues/109
Expand Down
41 changes: 31 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
FEniCS-preCICE adapter
----------------------

<a style="text-decoration: none" href="https://travis-ci.com/precice/fenics-adapter" target="_blank">
<img src="https://travis-ci.com/precice/fenics-adapter.svg?branch=master" alt="Build status">
</a>
<a style="text-decoration: none" href="https://github.com/precice/fenics-adapter/blob/master/LICENSE" target="_blank">
<img src="https://img.shields.io/github/license/precice/fenics-adapter.svg" alt="GNU LGPL license">
</a>

preCICE-adapter for the open source computing platform FEniCS
<a style="text-decoration: none" href="https://github.com/precice/fenics-adapter/actions/workflows/build-and-test.yml" target="_blank">
<img src="https://github.com/precice/fenics-adapter/actions/workflows/build-and-test.yml/badge.svg" alt="Build and Test">
</a>
<a style="text-decoration: none" href="https://github.com/precice/fenics-adapter/actions/workflows/run-tutorials.yml" target="_blank">
<img src="https://github.com/precice/fenics-adapter/actions/workflows/run-tutorials.yml/badge.svg" alt="Run preCICE Tutorials">
</a>
<a style="text-decoration: none" href="https://pypi.org/project/fenicsprecice/" target="_blank">
<img src="https://github.com/precice/fenics-adapter/actions/workflows/pythonpublish.yml/badge.svg" alt="Upload Python Package">
</a>

_**Note:** This adapter is currently purely expermental and limited in functionality. If you are interested in using it or you want to contribute, feel free to contact us via the [preCICE mailing list](https://mailman.informatik.uni-stuttgart.de/mailman/listinfo/precice)._
preCICE-adapter for the open source computing platform FEniCS

**currently only supports 2D simulations in FEniCS**

This adapter was developed by [Benjamin Rüth](https://www5.in.tum.de/wiki/index.php/Benjamin_R%C3%BCth,_M.Sc._(hons)) during his research stay at Lund University in the group for [Numerical Analysis](http://www.maths.lu.se/english/research/research-divisions/numerical-analysis/) in close collaboration with [Peter Meisrimel](https://www.lunduniversity.lu.se/lucat/user/09d80f0367a060bcf2a22d7c22e5e504).

# Installing the package

## Using pip3 to install from PyPI
Expand Down Expand Up @@ -53,18 +56,27 @@ Single tests can be also be run. For example the test `test_vector_write` in the
python3 -m unittest tests.test_write_read.TestWriteandReadData.test_vector_write
```

# Use the adapter
### Troubleshooting

Add ``from fenicsprecice import Adapter`` in your FEniCS code. Please refer to the examples in the [tutorials repository](https://github.com/precice/tutorials) for usage examples:
**FEniCS is suddenly broken:** There are two known issues with preCICE, fenicsprecice and FEniCS:

The adapter is configured via a `json` configuration file. For example configuration files and usage refer to the tutorials ([fenics-fenics](https://github.com/precice/tutorials/tree/master/HT/partitioned-heat/fenics-fenics)).
* If you see `ImportError: cannot import name 'sub_forms_by_domain'` run `pip3 uninstall -y fenics-ufl`. For details, refer to [issue #103](https://github.com/precice/fenics-adapter/issues/103).
* If you see `ModuleNotFoundError: No module named 'dolfin'` and have installed PETSc from source, refer to [this forum post](https://fenicsproject.discourse.group/t/modulenotfounderror-no-module-named-dolfin-if-petsc-dir-is-set/4407). Short version: Try to use the PETSc that comes with your system, if possible. Note that you can also [compile preCICE without PETSc](https://www.precice.org/installation-source-configuration.html), if necessary.

If this does not help, you can contact us on [gitter](https://gitter.im/precice/lobby) or [open an issue](https://github.com/precice/fenics-adapter/issues/new).

# Use the adapter

Please refer to [our website](https://www.precice.org/adapter-fenics.html#how-can-i-use-my-own-solver-with-the-adapter-).

# Packaging

To create and install the `fenicsprecice` python package the following instructions were used: https://python-packaging.readthedocs.io/en/latest/index.html.

# Citing

If you are using this adapter, please refer to the [citing information on the FEniCS adapter](https://www.precice.org/adapter-fenics.html#how-to-cite).

preCICE is an academic project, developed at the [Technical University of Munich](https://www5.in.tum.de/) and at the [University of Stuttgart](https://www.ipvs.uni-stuttgart.de/). If you use preCICE, please [cite us](https://www.precice.org/publications/):

*H.-J. Bungartz, F. Lindner, B. Gatzhammer, M. Mehl, K. Scheufele, A. Shukaev, and B. Uekermann: preCICE - A Fully Parallel Library for Multi-Physics Surface Coupling. Computers and Fluids, 141, 250–258, 2016.*
Expand All @@ -74,3 +86,12 @@ If you are using FEniCS, please also consider the information on https://fenicsp
# Disclaimer

This offering is not approved or endorsed by the FEniCS Project, producer and distributor of the FEniCS software via https://fenicsproject.org/.

# Development history

The initial version of this adapter was developed by [Benjamin Rodenberg](https://www.in.tum.de/i05/personen/personen/benjamin-rodenberg/) during his research stay at Lund University in the group for [Numerical Analysis](http://www.maths.lu.se/english/research/research-divisions/numerical-analysis/) in close collaboration with [Peter Meisrimel](https://www.lunduniversity.lu.se/lucat/user/09d80f0367a060bcf2a22d7c22e5e504).

[Richard Hertrich](https://github.com/richahert) contributed the possibility to perform FSI simulations using the adapter in his [Bachelor thesis](https://mediatum.ub.tum.de/node?id=1520579).

[Ishaan Desai](https://www.ipvs.uni-stuttgart.de/institute/team/Desai/) improved the user interface and extended the adapter to also allow for parallel FEniCS computations.

23 changes: 12 additions & 11 deletions docs/ReleaseGuide.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
## Guide to release new version of the FEniCS-preCICE adapter

The developer who is releasing a new version of FEniCS-preCICE adapter is expected to follow this work flow
Before starting this process make sure to check that all relevant changes are included in the `CHANGELOG.md`. The developer who is releasing a new version of FEniCS-preCICE adapter is expected to follow this workflow:

1. If it does not already exist, create a release branch with the version number of the planned release. Use develop as base for the branch. `git checkout develop`; `git checkout -b release_vX.X.X`. Perform the following steps only on the release branch, if not indicated differently.
1. If it does not already exist, create a release branch with the version number of the planned release. Use develop as base for the branch. `git checkout develop`; `git checkout -b fenics-adapter-vX.X.X`. Perform the following steps only on the release branch, if not indicated differently.

2. [Open a Pull Request from the branch `release_vX.X.X` to `master`](https://github.com/precice/fenics-adapter/compare) named after the version (i.e. `Release v1.0.0`) and briefly describe the new features of the release in the PR description.
2. [Open a Pull Request from the branch `fenics-adapter-vX.X.X` to `master`](https://github.com/precice/fenics-adapter/compare) named after the version (i.e. `Release v1.0.0`) and briefly describe the new features of the release in the PR description.

a) Check `CHANGELOG.md`, if necessary, update `CHANGELOG.md` on `develop` and merge into `release_vX.X.X`

b) Before merging the PR, make sure to bump the version in `CHANGELOG.md` on `release_vX.X.X`
3. Bump the version in the following places:

3. [Draft a New Release](https://github.com/precice/fenics-adapter/releases/new) in the `Releases` section of the repository page in a web browser. The release tag needs to be the exact version number (i.e.`v1.0.0` or `v1.0.0rc1`, compare to [existing tags](https://github.com/precice/fenics-adapter/tags)). Use `@target:master`. Release title is also the version number (i.e. `v1.0.0` or `v1.0.0rc1`, compare to [existing releases](https://github.com/precice/fenics-adapter/tags)).
*Note:* If it is a pre-release then the option *This is a pre-release* needs to be selected at the bottom of the page. Use `@target:release_vX.X.X` for a pre-release, since we will never merge a pre-release into master.
a) Before merging the PR, make sure to bump the version in `CHANGELOG.md` on `fenics-adapter-vX.X.X`
b) There is no need to bump the version anywhere else, since we use the [python-versioneer](https://github.com/python-versioneer/python-versioneer/) for maintaining the version everywhere else.

4. [Draft a New Release](https://github.com/precice/fenics-adapter/releases/new) in the `Releases` section of the repository page in a web browser. The release tag needs to be the exact version number (i.e.`v1.0.0` or `v1.0.0rc1`, compare to [existing tags](https://github.com/precice/fenics-adapter/tags)). Use `@target:master`. Release title is also the version number (i.e. `v1.0.0` or `v1.0.0rc1`, compare to [existing releases](https://github.com/precice/fenics-adapter/tags)).
*Note:* If it is a pre-release then the option *This is a pre-release* needs to be selected at the bottom of the page. Use `@target:fenics-adapter-vX.X.X` for a pre-release, since we will never merge a pre-release into master.

a) If a pre-release is made: Directly hit the "Publish release" button in your Release Draft. Now you can check the artifacts (e.g. release on [PyPI](https://pypi.org/project/fenicsprecice/#history)) of the release. *Note:* As soon as a new tag is created github actions will take care of deploying the new version on PyPI using [this workflow](https://github.com/precice/fenics-adapter/actions?query=workflow%3A%22Upload+Python+Package%22).

b) If this is a "real" release: As soon as one approving review is made, merge the release PR (`release_vX.X.X`) into `master`.
b) If this is a "real" release: As soon as one approving review is made, merge the release PR (`fenics-adapter-vX.X.X`) into `master`.

4. Merge `master` into `develop` for synchronization of `develop`.
5. Merge `master` into `develop` for synchronization of `develop`.

5. If everything is in order up to this point then the new version can be released by hitting the "Publish release" button in your Release Draft.
6. If everything is in order up to this point then the new version can be released by hitting the "Publish release" button in your Release Draft.
8 changes: 0 additions & 8 deletions fenicsadapter/__init__.py

This file was deleted.

21 changes: 12 additions & 9 deletions fenicsprecice/adapter_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Vertices:
Vertices class provides a generic skeleton for vertices. A set of vertices has a set of global IDs, local IDs and
coordinates as defined in FEniCS.
"""

def __init__(self, vertex_type):
self._vertex_type = vertex_type
self._global_ids = None
Expand Down Expand Up @@ -91,12 +92,12 @@ def determine_function_type(input_obj):
tag : bool
0 if input_function is SCALAR and 1 if input_function is VECTOR.
"""
if type(input_obj) == FunctionSpace: # scalar-valued functions have rank 0 is FEniCS
if isinstance(input_obj, FunctionSpace): # scalar-valued functions have rank 0 is FEniCS
if input_obj.num_sub_spaces() == 0:
return FunctionType.SCALAR
elif input_obj.num_sub_spaces() == 2:
return FunctionType.VECTOR
elif type(input_obj) == Function:
elif isinstance(input_obj, Function):
if input_obj.value_rank() == 0:
return FunctionType.SCALAR
elif input_obj.value_rank() == 1:
Expand All @@ -107,7 +108,7 @@ def determine_function_type(input_obj):
raise Exception("Error determining type of given dolfin FunctionSpace")


def filter_point_sources(point_sources, filter_out):
def filter_point_sources(point_sources, filter_out, warn_duplicate=True):
"""
Filter dictionary of PointSources (point_sources) with respect to a given domain (filter_out). If a PointSource
is applied at a point inside of the given domain (filter_out), this PointSource will be removed from dictionary.
Expand All @@ -118,6 +119,8 @@ def filter_point_sources(point_sources, filter_out):
Dictionary containing coordinates and associated PointSources {(point_x, point_y): PointSource, ...}.
filter_out: FEniCS domain
Defines the domain where PointSources should be filtered out.
warn_duplicate: bool
Set False to surpress warnings, if double-boundary points are filtered out.
Returns
-------
Expand All @@ -128,10 +131,10 @@ def filter_point_sources(point_sources, filter_out):

for point in point_sources.keys():
# Filter double boundary points to avoid instabilities and create PointSource
if filter_out.inside(point, 1):
print("Found a double-boundary point at {location}.".format(location=point))
else:
if not filter_out.inside(point, 1):
filtered_point_sources[point] = point_sources[point]
elif warn_duplicate:
logger.warning("Found a double-boundary point at {location}.".format(location=point))

return filtered_point_sources

Expand All @@ -153,7 +156,7 @@ def convert_fenics_to_precice(fenics_function, local_ids):
Array of FEniCS function values at each point on the boundary.
"""

if type(fenics_function) is not Function:
if not isinstance(fenics_function, Function):
raise Exception("Cannot handle data type {}".format(type(fenics_function)))

precice_data = []
Expand Down Expand Up @@ -382,8 +385,8 @@ def get_forces_as_point_sources(fixed_boundary, function_space, data):
y_forces[key] = PointSource(function_space.sub(1), Point(px, py), nodal_data[i, 1])

# Avoid application of PointSource and Dirichlet boundary condition at the same point by filtering
x_forces = filter_point_sources(x_forces, fixed_boundary)
y_forces = filter_point_sources(y_forces, fixed_boundary)
x_forces = filter_point_sources(x_forces, fixed_boundary, warn_duplicate=False)
y_forces = filter_point_sources(y_forces, fixed_boundary, warn_duplicate=False)

return x_forces.values(), y_forces.values() # don't return dictionary, but list of PointSources

Expand Down
5 changes: 3 additions & 2 deletions fenicsprecice/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Config:
configuration file. Initializer calls read_json() method. Instance attributes
can be accessed by provided getter functions.
"""

def __init__(self, adapter_config_filename):

self._config_file_name = None
Expand Down Expand Up @@ -42,12 +43,12 @@ def read_json(self, adapter_config_filename):

try:
self._write_data_name = data["interface"]["write_data_name"]
except:
except KeyError:
self._write_data_name = None # not required for one-way coupling, if this participant reads data

try:
self._read_data_name = data["interface"]["read_data_name"]
except:
except KeyError:
self._read_data_name = None # not required for one-way coupling, if this participant writes data

read_file.close()
Expand Down
Loading

0 comments on commit beabcd1

Please sign in to comment.