Skip to content

Commit

Permalink
Release PreCICE.jl v2.4.0 (#38)
Browse files Browse the repository at this point in the history
* Change version

* Correct TagBot

* Try _ to seperate PreCICE from bindings version

* Seperate bindings version with a `-`

* Change version to release candidate `2.4.0-0-rc1`

* Add formatter workflow (#31)

* Update README

* Add formatter workflow

* Format every current file

* New line at the end of the file

* Revert README changes

* Run format on each push on all branches

* Update README with general repository and troubleshooting (#30)

* Update README

* Minor edits to README

Co-authored-by: Ishaan Desai <ishaandesai@gmail.com>

* Fix bug: readScalarData returns wrong value (#33)

* Fix wrong transposes (#35)

* Add tests for Package functions (#32)

* Update README

* Add formatter workflow

* Format every current file

* New line at the end of the file

* Revert README changes

* Run format on each push on all branches

* [WIP] Set up testing for all functions

* [WIP] Set up testing for all functions

* Correct some errors and types

* Use string compare and debugging

* Debugging

* Undo Integer convert

* Don't use range for 1.6 compat

* integer to Cint

* Merge develop into testing

* Seperate Functioncall tests

* Add info message where to run `make`

* Format

* Move function tests back to the rest

* Undo documentation changes for now unchanged functions

* Add user info where to run `make`

* Update test workflow to include function tests

* Undo changes to workflow and Fix runtests

* Update Readme

* Test excluding julia x86 architecture

* Test running tests manually

* Undo workflow changes

* Compile Fake solverdummy

* Install make in workflow

* no sudo

* make instead of build essential

* update and apt

* Add info on how to compile fake SolveIinterface.c

* Change command in user info

* Update README.md

Co-authored-by: Ishaan Desai <ishaandesai@gmail.com>

* Update README.md

Co-authored-by: Ishaan Desai <ishaandesai@gmail.com>

* Review Changes

Co-authored-by: Ishaan Desai <ishaandesai@gmail.com>

* Remove meshName from arguments (#36)

* Remove meshName from arguments

* Remove MeshName from solverdummy test

* Format

* Fix tests (#37)

* Fix tests

* Remove unecessary comment

* Update version number

Co-authored-by: Ishaan Desai <ishaandesai@gmail.com>
  • Loading branch information
erikscheurer and IshaanDesai authored May 21, 2022
1 parent a4d99e7 commit 13c368c
Show file tree
Hide file tree
Showing 15 changed files with 1,010 additions and 154 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,15 @@ jobs:
- name: Build Package
uses: julia-actions/julia-buildpkg@v1

- name: install make
run: |
apt update
apt install make
- name: Build Fake Solverinterface
run: |
cd test
make
- name: Run tests
uses: julia-actions/julia-runtest@v1
36 changes: 36 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: format-check

on:
push

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.6.0]
os: [ubuntu-latest]
steps:
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}

- uses: actions/checkout@v1
- name: Install JuliaFormatter and format
# This will use the latest version by default but you can set the version like so:
#
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia -e 'using JuliaFormatter; format(".", verbose=true)'
- name: Format check
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "Some files have not been formatted !!!"
write(stdout, out)
exit(1)
end'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ binarybuilder
solverdummy/*.log
solverdummy/*.json
solverdummy/precice-run/
*.o
*.so
deps/build.log
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PreCICE"
uuid = "57fbd4af-5cc3-4712-aac0-6930e7658184"
authors = ["preCICE <https://precice.org/> and contributors"]
version = "0.0.1"
version = "2.4.0"

[compat]
julia = "1.6"
Expand Down
51 changes: 31 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,53 @@ This package provides Julia language bindings for the C++ library [preCICE](http

## Adding and using the package

You can use the Julia bindings for preCICE by adding them as a package in a Julia environment or also directly including the package in a Julia script. For both type of usages you need to have preCICE installed on the system. For preCICE installation you can look at the [installation documentation](https://precice.org/installation-overview.html).
The Julia bindings for preCICE can be used by either by adding them as a package in a Julia environment or also directly including the package in a Julia script. For both type of usages preCICE needs to be installed on the system. For preCICE installation, have a look at the [installation documentation](https://precice.org/installation-overview.html).

### Adding the package using the repository link
### Adding the package

Add the Julia bindings to the Julia environment in the following way:

```julia
julia> ]
pkg> add https://github.com/precice/julia-bindings.git
pkg> add PreCICE
Then exit the package mode with 🔙 or Ctrl + c
julia> using PreCICE
```

Alternatively you can also include the package in a Julia script in the following way:

```julia
import Pkg; Pkg.add(url="https://github.com/precice/julia-bindings.git")
import Pkg; Pkg.add("PreCICE")
using PreCICE
```

### Adding the package from a local folder

If you have cloned or downloaded the Julia bindings on your local machine, add the Julia bindings to your Julia environment in the following way:

```julia
```julia-repl
julia> ]
pkg> add <path-to-repository>
Then exit the package mode with 🔙 or Ctrl + c
julia> using PreCICE
```

## Adding the package when preCICE is installed at a custom path
Alternatively, you can install a specific branch of this repository with the following command:
```julia-repl
pkg> add https://github.com/precice/PreCICE.jl#<branch-name>
```

If you installed preCICE at a custom path, errors of the form ```ERROR: could not load library "/..."``` can occur after adding the Julia bindings package.
## Troubleshooting

Set your custom path through the environment variable `PRECICE_JL_BINARY` and rebuild this package:
If preCICE is installed at a custom path, errors of the form ```ERROR: could not load library "/..."``` can occur after adding the Julia bindings package. Make sure the preCICE library is in the system library path through `echo $LD_LIBRARY_PATH` and otherwise update the variable with the correct path.

```julia
```bash
~$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<path-to-precice.so>
```

A different way to fix this error is to set the custom path of the preCICE installation through the environment variable `PRECICE_JL_BINARY`. Afterwards you need to rebuild this package:

```julia-repl
~$ export PRECICE_JL_BINARY=/usr/lib/x86_64-linux-gnu/
~$ julia (--project)
julia> ]
Expand All @@ -56,27 +65,29 @@ julia> using PreCICE

## Usage

You can look at [solverdummy](https://github.com/precice/julia-bindings/tree/main/solverdummy) as an example of how to use the Julia bindings for preCICE.

## Testing new features that are on branches of this repository
The [solverdummy](https://github.com/precice/julia-bindings/tree/main/solverdummy) shows an example of how to use the Julia bindings for preCICE.

To use a certain branch of this package, add `#branchname` after the package url, for example if the branch `mpi-parallelization` is to be tested:
## Testing PreCICE.jl

```julia
To test the bindings, run:
```julia-repl
julia> ]
pkg> add https://github.com/precice/julia-bindings.git#mpi-parallelization
Then exit the package mode with 🔙 or Ctrl + c
julia> using PreCICE
pkg> test PreCICE
```

This checks if the preCICE bindings can be found and accessed correctly.
You can also test the full functionality of PreCICE.jl. If not set up, the output of the previous test shows an info on what command you need to execute. It will be along the lines of:
```
cd /home/<user>/.julia/packages/PreCICE/<code>/test && make
```
After this, you can run the tests again, resulting individual 22 tests being executed.

## Dependencies

This package works with official Julia binaries listed below. See the [Platform Specific Instructions for official Binaries](https://julialang.org/downloads/platform/) or [Julia's documentation](https://docs.julialang.org/en/v1/manual/getting-started/) if you are not sure how to download them.

## Supported versions

The package is tested for Julia versions `1.6.0`, `1.6.5`, `1.7.0` and the two newest [Julia releases](https://github.com/JuliaLang/julia/releases).

Versions prior to `v1.6.0` are not supported.
The package is tested for Julia versions `1.6.0`, `1.6.5`, `1.7.0` and the two newest [Julia releases](https://github.com/JuliaLang/julia/releases). Julia versions prior to `v1.6.0` are not supported.

[Unofficial Julia binaries](https://julialang.org/downloads/platform/#platform_specific_instructions_for_unofficial_binaries) may not be compatible.
6 changes: 3 additions & 3 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if VERSION<v"1.6"
if VERSION < v"1.6"
error("Julia version $VERSION not compatible with PreCICE Adapter")
end

Expand All @@ -10,10 +10,10 @@ if haskey(ENV, "PRECICE_JL_BINARY")
try
Libc.Libdl.dlopen(libprecice)
push!(Libc.Libdl.DL_LOAD_PATH, libprecice)
catch e
catch e
@warn "could not load custom preCICE binary at location: $libprecice"
@warn "will search the system locations for a valid library."
throw(e)
end

end
4 changes: 2 additions & 2 deletions solverdummy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ This is a minimal working example for using preCICEC.jl with Julia. The solverdu

From this directory, run
```
julia ./solverdummy.jl ./precice-config.xml SolverOne MeshOne
julia ./solverdummy.jl ./precice-config.xml SolverOne
```

or

```
julia ./solverdummy.jl ./precice-config.xml SolverTwo MeshTwo
julia ./solverdummy.jl ./precice-config.xml SolverTwo
```

respectively.
72 changes: 38 additions & 34 deletions solverdummy/solverdummy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ using PreCICE
commRank = 0
commSize = 1

if size(ARGS, 1) < 2
println("ERROR: pass config path, solver name and mesh name, example: julia solverdummy.jl ./precice-config.xml SolverOne MeshOne")
if size(ARGS, 1) < 1
@error(
"ERROR: pass config path and solver name, example: julia solverdummy.jl ./precice-config.xml SolverOne",
)
exit(1)
end

Expand All @@ -15,15 +17,17 @@ solverName = ARGS[2]
if solverName == "SolverOne"
meshName = "MeshOne"
dataWriteName = "dataOne"
dataReadName = "dataTwo"
dataReadName = "dataTwo"
else
meshName = "MeshTwo"
dataReadName = "dataOne"
dataReadName = "dataOne"
dataWriteName = "dataTwo"
end


println("""DUMMY: Running solver dummy with preCICE config file "$configFileName", participant name "$solverName", and mesh name "$meshName" """)
println(
"""DUMMY: Running solver dummy with preCICE config file "$configFileName", participant name "$solverName", and mesh name "$meshName" """,
)
PreCICE.createSolverInterface(solverName, configFileName, commRank, commSize)

meshID = PreCICE.getMeshID(meshName)
Expand All @@ -33,53 +37,53 @@ dimensions = PreCICE.getDimensions()
numberOfVertices = 3


readDataID = PreCICE.getDataID(dataReadName, meshID)
readDataID = PreCICE.getDataID(dataReadName, meshID)
writeDataID = PreCICE.getDataID(dataWriteName, meshID)

writeData = zeros(numberOfVertices, dimensions)

vertices = Array{Float64, 2}(undef, numberOfVertices, dimensions)
vertices = Array{Float64,2}(undef, numberOfVertices, dimensions)

for i in 1:numberOfVertices, j in 1:dimensions
vertices[i,j] = i
for i = 1:numberOfVertices, j = 1:dimensions
vertices[i, j] = i
end

vertexIDs = PreCICE.setMeshVertices(meshID, vertices)

let # setting local scope for dt outside of the while loop

dt = PreCICE.initialize()
readData = zeros(numberOfVertices, dimensions)
dt = PreCICE.initialize()
readData = zeros(numberOfVertices, dimensions)

while PreCICE.isCouplingOngoing()

if PreCICE.isActionRequired(PreCICE.actionWriteIterationCheckpoint())
println("DUMMY: Writing iteration checkpoint")
PreCICE.markActionFulfilled(PreCICE.actionWriteIterationCheckpoint())
end
while PreCICE.isCouplingOngoing()

if PreCICE.isReadDataAvailable()
readData = PreCICE.readBlockVectorData(readDataID, vertexIDs)
end
if PreCICE.isActionRequired(PreCICE.actionWriteIterationCheckpoint())
println("DUMMY: Writing iteration checkpoint")
PreCICE.markActionFulfilled(PreCICE.actionWriteIterationCheckpoint())
end

for i in 1:numberOfVertices,j in 1:dimensions
writeData[i,j] = readData[i,j] + 1.0
end
if PreCICE.isReadDataAvailable()
readData = PreCICE.readBlockVectorData(readDataID, vertexIDs)
end

if PreCICE.isWriteDataRequired(dt)
PreCICE.writeBlockVectorData(writeDataID, vertexIDs, writeData)
end
for i = 1:numberOfVertices, j = 1:dimensions
writeData[i, j] = readData[i, j] + 1.0
end

dt = PreCICE.advance(dt)
if PreCICE.isWriteDataRequired(dt)
PreCICE.writeBlockVectorData(writeDataID, vertexIDs, writeData)
end

if PreCICE.isActionRequired(PreCICE.actionReadIterationCheckpoint())
println("DUMMY: Reading iteration checkpoint")
PreCICE.markActionFulfilled(PreCICE.actionReadIterationCheckpoint())
else
println("DUMMY: Advancing in time")
end
dt = PreCICE.advance(dt)

end # while
if PreCICE.isActionRequired(PreCICE.actionReadIterationCheckpoint())
println("DUMMY: Reading iteration checkpoint")
PreCICE.markActionFulfilled(PreCICE.actionReadIterationCheckpoint())
else
println("DUMMY: Advancing in time")
end

end # while

end # let

Expand Down
Loading

0 comments on commit 13c368c

Please sign in to comment.