Skip to content

Commit

Permalink
Merge pull request #171 from precice/fenics-adapter-v2.1.0
Browse files Browse the repository at this point in the history
Release v2.1.0
  • Loading branch information
IshaanDesai authored Mar 19, 2024
2 parents fee4d4b + e01e2fd commit f3abeb0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# FEniCS-preCICE adapter changelog

## 2.1.0

* Additionally support checkpoints being provided as a list or tuple (of FEniCS Functions). [#170](https://github.com/precice/fenics-adapter/pull/170)

## 2.0.0

* Drop support for preCICE 2.x version, as this is a breaking release.
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract: >-
preCICE-adapter for the open source computing platform
FEniCS.
license: LGPL-3.0
version: 2.0.0
version: 2.1.0
preferred-citation:
title: "FEniCS-preCICE: Coupling FEniCS to other Simulation Software"
type: "article"
Expand Down
4 changes: 3 additions & 1 deletion docs/ReleaseGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Before starting this process make sure to check that all relevant changes are in

a) Before merging the PR, make sure to bump the version in `CHANGELOG.md` on `fenics-adapter-vX.X.X`.

b) Update the version in `CITATION.cff` and update the release date.
b) Update the version in `CITATION.cff`.

c) 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.

Expand All @@ -24,3 +24,5 @@ Before starting this process make sure to check that all relevant changes are in
5. Merge `master` into `develop` for synchronization of `develop`.

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.

7. Now there should be a tag for the release. Re-run the [docker release workflow `build-docker.yml` via dispatch](https://github.com/precice/fenics-adapter/actions/workflows/build-docker.yml) such that the correct version is picked up by `versioneer`. Check the version in the container via `docker pull precice/fenics-adapter`, then `docker run -ti precice/fenics-adapter`, and inside the container `$ python3 -c "import fenicsprecice; print(fenicsprecice.__version__)"`.
11 changes: 4 additions & 7 deletions fenicsprecice/fenicsprecice.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,14 @@ def initialize(self, coupling_subdomain, read_function_space=None, write_object=

self._participant.initialize()

def store_checkpoint(self, user_u, t, n):
def store_checkpoint(self, payload, t, n):
"""
Defines an object of class SolverState which stores the current state of the variable and the time stamp.
Parameters
----------
user_u : FEniCS Function
Current state of the physical variable of interest for this participant.
payload : fenics.function or a list of fenics.functions
Current state of the physical variable(s) of interest for this participant.
t : double
Current simulation time.
n : int
Expand All @@ -449,10 +449,7 @@ def store_checkpoint(self, user_u, t, n):
assert (self.is_time_window_complete())

logger.debug("Store checkpoint")
my_u = user_u.copy()
# making sure that the FEniCS function provided by user is not directly accessed by the Adapter
assert (my_u != user_u)
self._checkpoint = SolverState(my_u, t, n)
self._checkpoint = SolverState(payload, t, n)

def retrieve_checkpoint(self):
"""
Expand Down
29 changes: 18 additions & 11 deletions fenicsprecice/solverstate.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
class SolverState:
def __init__(self, u, t, n):
def __init__(self, payload, t, n):
"""
Solver state consists of a value u, associated time t and the timestep n
Solver state consists of a payload (either a single fenics.Function or a list of several fenics.Functions), associated time t and the timestep n
Parameters
----------
u : Object of class dolfin.functions.function.Function
FEniCS function related to the field during each coupling iteration.
payload : A fenics.Function or a list of fenics.Functions
Describes the state of the solver.
t : double
Time stamp.
n : int
Iteration number.
"""
self.u = u
try:
self.payload = payload.copy()
except AttributeError: # if .copy() does not exist, it probably is a list
self.payload = [item.copy() for item in payload]

self.t = t
self.n = n

def get_state(self):
"""
Returns the state variables value u, associated time t and timestep n
Returns the state variables payload, associated time t and timestep n
Returns
-------
u : Object of class dolfin.functions.function.Function
A copy of FEniCS function related to the field during each coupling iteration.
payload : A fenics.Function or a list of fenics.Functions
Describes the state of the solver.
t : double
Time stamp.
n : int
Iteration number.
"""
return self.u.copy(), self.t, self.n
try:
return self.payload.copy(), self.t, self.n
except AttributeError: # if .copy() does not exist, it probably is a list
return [item.copy() for item in self.payload], self.t, self.n

def print_state(self):
u, t, n = self.get_state()
return print("u={u}, t={t}, n={n}".format(u=u, t=t, n=n))
payload, t, n = self.get_state()
return print(f"payload={payload}, t={t}, n={n}")

0 comments on commit f3abeb0

Please sign in to comment.