Skip to content

Commit beabcd1

Browse files
authored
Merge pull request #122 from precice/fenics-adapter-v1.1.0
Release v1.1.0
2 parents bd74827 + 15be563 commit beabcd1

20 files changed

+228
-101
lines changed

.github/workflows/build-and-test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ jobs:
1818
uses: actions/checkout@v2
1919
- name: Install fake precice
2020
run: |
21-
mkdir -p precice
21+
mkdir -p precice
2222
echo "from setuptools import setup" >> precice/setup.py
2323
echo "setup(name='pyprecice', version='2.0.2.1')" >> precice/setup.py
2424
python3 -m pip install ./precice/
2525
- name: Run unit tests
26-
run: python3 setup.py test
26+
run: python3 setup.py test -s tests.unit
27+
- name: Run integration tests
28+
run: python3 setup.py test -s tests.integration

.github/workflows/check-pep8.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: autopep8
2+
on: push
3+
jobs:
4+
autopep8:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v2
8+
- name: autopep8
9+
id: autopep8
10+
uses: peter-evans/autopep8@v1
11+
with:
12+
args: --recursive --diff --aggressive --aggressive --exit-code --ignore E402 --max-line-length 120 .
13+
- name: Fail if autopep8 made changes
14+
if: ${{ steps.autopep8.outputs.exit-code == 2 }}
15+
run: exit 1
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Run preCICE Tutorials
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- develop
7+
pull_request:
8+
paths:
9+
- '**'
10+
11+
jobs:
12+
run_ht_simple:
13+
name: Run HT, simple
14+
runs-on: ubuntu-latest
15+
container: precice/precice
16+
steps:
17+
- name: Checkout Repository
18+
uses: actions/checkout@v2
19+
- name: Install Dependencies & FEniCS
20+
run: |
21+
apt-get -qq update
22+
apt-get -qq install software-properties-common python3-dev python3-pip git apt-utils
23+
add-apt-repository -y ppa:fenics-packages/fenics
24+
apt-get -qq install --no-install-recommends fenics
25+
rm -rf /var/lib/apt/lists/*
26+
- name: Install adapter
27+
run: pip3 install --user .
28+
- name: Fix broken FEniCS installation (see https://fenicsproject.discourse.group/t/installing-python-package-with-fenics-dependency-breaks-fenics-installation/4476)
29+
run: pip3 uninstall -y fenics-ufl
30+
- name: Get tutorials
31+
run: git clone -b develop https://github.com/precice/tutorials.git
32+
- name: Run tutorial
33+
run: |
34+
cd tutorials/partitioned-heat-conduction/fenics
35+
python3 heat.py -d & python3 heat.py -n
36+
37+
run_ht_complex:
38+
name: Run HT, complex
39+
runs-on: ubuntu-latest
40+
container: precice/precice
41+
steps:
42+
- name: Checkout Repository
43+
uses: actions/checkout@v2
44+
- name: Install Dependencies & FEniCS
45+
run: |
46+
apt-get -qq update
47+
apt-get -qq install software-properties-common python3-dev python3-pip git apt-utils
48+
add-apt-repository -y ppa:fenics-packages/fenics
49+
apt-get -qq install --no-install-recommends fenics
50+
rm -rf /var/lib/apt/lists/*
51+
- name: Install adapter
52+
run: pip3 install --user .
53+
- name: Fix broken FEniCS installation (see https://fenicsproject.discourse.group/t/installing-python-package-with-fenics-dependency-breaks-fenics-installation/4476)
54+
run: pip3 uninstall -y fenics-ufl
55+
- name: Get tutorials
56+
run: git clone -b develop https://github.com/precice/tutorials.git
57+
- name: Run tutorial
58+
run: |
59+
cd tutorials/partitioned-heat-conduction-complex/fenics
60+
python3 heat.py -d -i complex & python3 heat.py -n -i complex

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
matrix:
1+
matrix:
2+
allow_failures:
3+
- name: "Systemtests [failure allowed]"
24
include:
35
- os: linux
4-
name: "Systemtests"
6+
name: "Systemtests [failure allowed]"
57
if: fork = false AND ( branch = master OR branch = develop )
68
python: "3.6"
79
env: PY=python3

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# FEniCS-preCICE adapter changelog
22

3+
## 1.1.0
4+
5+
* Only warn during initialization, if duplicate boundary point is found for point sources.
6+
* Remove deprecated package `fenicsadapter`. Don't use `import fenicsadapter`. Please use `import fenicsprecice`. https://github.com/precice/fenics-adapter/pull/121
7+
38
## 1.0.1
49

510
* Bugfix for PointSources https://github.com/precice/fenics-adapter/issues/109

README.md

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
FEniCS-preCICE adapter
22
----------------------
33

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

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

13-
_**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)._
18+
preCICE-adapter for the open source computing platform FEniCS
1419

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

17-
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).
18-
1922
# Installing the package
2023

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

56-
# Use the adapter
59+
### Troubleshooting
5760

58-
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:
61+
**FEniCS is suddenly broken:** There are two known issues with preCICE, fenicsprecice and FEniCS:
5962

60-
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)).
63+
* 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).
64+
* 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.
65+
66+
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).
67+
68+
# Use the adapter
69+
70+
Please refer to [our website](https://www.precice.org/adapter-fenics.html#how-can-i-use-my-own-solver-with-the-adapter-).
6171

6272
# Packaging
6373

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

6676
# Citing
6777

78+
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).
79+
6880
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/):
6981

7082
*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.*
@@ -74,3 +86,12 @@ If you are using FEniCS, please also consider the information on https://fenicsp
7486
# Disclaimer
7587

7688
This offering is not approved or endorsed by the FEniCS Project, producer and distributor of the FEniCS software via https://fenicsproject.org/.
89+
90+
# Development history
91+
92+
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).
93+
94+
[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).
95+
96+
[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.
97+

docs/ReleaseGuide.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
## Guide to release new version of the FEniCS-preCICE adapter
22

3-
The developer who is releasing a new version of FEniCS-preCICE adapter is expected to follow this work flow
3+
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:
44

5-
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.
5+
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.
66

7-
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.
7+
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.
88

9-
a) Check `CHANGELOG.md`, if necessary, update `CHANGELOG.md` on `develop` and merge into `release_vX.X.X`
10-
11-
b) Before merging the PR, make sure to bump the version in `CHANGELOG.md` on `release_vX.X.X`
9+
3. Bump the version in the following places:
1210

13-
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)).
14-
*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.
11+
a) Before merging the PR, make sure to bump the version in `CHANGELOG.md` on `fenics-adapter-vX.X.X`
12+
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.
13+
14+
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)).
15+
*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.
1516

1617
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).
1718

18-
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`.
19+
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`.
1920

20-
4. Merge `master` into `develop` for synchronization of `develop`.
21+
5. Merge `master` into `develop` for synchronization of `develop`.
2122

22-
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.
23+
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.

fenicsadapter/__init__.py

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

fenicsprecice/adapter_core.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Vertices:
3232
Vertices class provides a generic skeleton for vertices. A set of vertices has a set of global IDs, local IDs and
3333
coordinates as defined in FEniCS.
3434
"""
35+
3536
def __init__(self, vertex_type):
3637
self._vertex_type = vertex_type
3738
self._global_ids = None
@@ -91,12 +92,12 @@ def determine_function_type(input_obj):
9192
tag : bool
9293
0 if input_function is SCALAR and 1 if input_function is VECTOR.
9394
"""
94-
if type(input_obj) == FunctionSpace: # scalar-valued functions have rank 0 is FEniCS
95+
if isinstance(input_obj, FunctionSpace): # scalar-valued functions have rank 0 is FEniCS
9596
if input_obj.num_sub_spaces() == 0:
9697
return FunctionType.SCALAR
9798
elif input_obj.num_sub_spaces() == 2:
9899
return FunctionType.VECTOR
99-
elif type(input_obj) == Function:
100+
elif isinstance(input_obj, Function):
100101
if input_obj.value_rank() == 0:
101102
return FunctionType.SCALAR
102103
elif input_obj.value_rank() == 1:
@@ -107,7 +108,7 @@ def determine_function_type(input_obj):
107108
raise Exception("Error determining type of given dolfin FunctionSpace")
108109

109110

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

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

136139
return filtered_point_sources
137140

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

156-
if type(fenics_function) is not Function:
159+
if not isinstance(fenics_function, Function):
157160
raise Exception("Cannot handle data type {}".format(type(fenics_function)))
158161

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

384387
# Avoid application of PointSource and Dirichlet boundary condition at the same point by filtering
385-
x_forces = filter_point_sources(x_forces, fixed_boundary)
386-
y_forces = filter_point_sources(y_forces, fixed_boundary)
388+
x_forces = filter_point_sources(x_forces, fixed_boundary, warn_duplicate=False)
389+
y_forces = filter_point_sources(y_forces, fixed_boundary, warn_duplicate=False)
387390

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

fenicsprecice/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Config:
1313
configuration file. Initializer calls read_json() method. Instance attributes
1414
can be accessed by provided getter functions.
1515
"""
16+
1617
def __init__(self, adapter_config_filename):
1718

1819
self._config_file_name = None
@@ -42,12 +43,12 @@ def read_json(self, adapter_config_filename):
4243

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

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

5354
read_file.close()

0 commit comments

Comments
 (0)