Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross merge rc-3.5.4 to dev #2333

Merged
merged 14 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
# This workflow builds an OpenFAST docker image for the linux/amd64 and linux/aarch64 architectures on merge into
# `main` from a release candidate branch. The image is tagged both with "latest" and the version extracted from the
# release candidate branch's name (e.g. "rc-3.5.3") before being pushed to the `nrel/openfast` repository. The build
# cache is stored in GitHub actions.
name: build-docker-image-automatic
# This workflow uploads the `openfast` python package to PyPI before building an OpenFAST docker image for the
# linux/amd64 and linux/aarch64 architectures on release. The image is tagged both with "latest" and the version
# extracted from the release candidate branch's name (e.g. "rc-3.5.3") before being pushed to the `nrel/openfast`
# repository. The build cache is stored in GitHub actions.
name: deploy

on:
workflow_dispatch:

release:
types:
- released

jobs:
build-and-push:
publish-to-pypi:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Poetry
uses: snok/install-poetry@v1.3.4

- name: Build a binary wheel and a source tarball
run: poetry build
working-directory: openfast_python

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@v1.8.14
with:
packages-dir: openfast_python/dist


docker-build-and-push:
runs-on: ubuntu-latest
timeout-minutes: 300
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ vs-build/
.fortls
.devcontainer
.idea
.env

# backup files
*.asv
Expand Down
28 changes: 26 additions & 2 deletions docs/source/install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ code,** refer to the table in the :ref:`download_binaries` or :ref:`use_docker`
sections and read the corresponding documentation for specific instructions.
For instructions on compiling, see :ref:`compile_from_source`.

To manipulate OpenFAST files using python, see :ref:`python_wrapper`.


.. _download_binaries:

Download binaries
Expand Down Expand Up @@ -193,21 +196,42 @@ To pull and run with local files:

.. code-block:: shell

docker run --rm -it --volume=/path/to/files:/files ghcr.io/OpenFAST/openfast:latest openfast /files/main.fst
docker run --rm -it --volume=/path/to/files:/files ghcr.io/openfast/openfast:latest openfast /files/main.fst

For running the container interactively:

.. code-block:: shell

docker run --rm -it --volume=/path/to/files:/files ghcr.io/OpenFAST/openfast:latest /bin/bash
docker run --rm -it --volume=/path/to/files:/files ghcr.io/openfast/openfast:latest /bin/bash

To pull a specific release, substitute the version number in place of `latest` in the above commands (i.e. `ghcr.io/openfast/openfast:3.5.3`).

Build your own images
---------------------
You can also build your own custom images using our `Dockerfile` or base your images on ours. See
`here <https://github.com/OpenFAST/openfast/blob/main/share/docker/README.md>`_ for more information on this.


.. _python_wrapper

Install the ``openfast_io`` python wrapper
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The ``openfast_io`` python package is a wrapper comprising readers and writers for converting OpenFAST files to/from
python objects. You can install it with:

.. code-block::

pip install openfast_io

or

.. code-block::

poetry add openfast_io

For more information and installation options, see `here <https://github.com/OpenFAST/openfast/blob/main/openfast_python/README.md>`_.


.. _compile_from_source:

Compile from source
Expand Down
57 changes: 33 additions & 24 deletions glue-codes/openfast-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ find_package(LibXml2 REQUIRED)
find_package(ZLIB REQUIRED)
find_package(HDF5 REQUIRED)
find_package(NetCDF REQUIRED COMPONENTS C)
find_package(yaml-cpp REQUIRED)

add_library(openfastcpplib
src/OpenFAST.cpp
src/SC.cpp
)
add_library(openfastcpplib SHARED src/OpenFAST.cpp src/SC.cpp)
set_property(TARGET openfastcpplib PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(openfastcpplib
openfastlib
Expand All @@ -52,28 +48,41 @@ target_include_directories(openfastcpplib PUBLIC
)
set_target_properties(openfastcpplib PROPERTIES PUBLIC_HEADER "src/OpenFAST.H;src/SC.h")

add_executable(openfastcpp src/FAST_Prog.cpp)
target_link_libraries(openfastcpp
${YAML_CPP_LIBRARIES}
openfastcpplib
)
target_include_directories(openfastcpp PRIVATE ${YAML_CPP_INCLUDE_DIR})
set_target_properties(openfastcpp PROPERTIES LINKER_LANGUAGE CXX)

if(MPI_COMPILE_FLAGS)
set_target_properties(openfastcpp PROPERTIES
COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
endif(MPI_COMPILE_FLAGS)

if(MPI_LINK_FLAGS)
set_target_properties(openfastcpp PROPERTIES
LINK_FLAGS "${MPI_LINK_FLAGS}")
endif(MPI_LINK_FLAGS)

install(TARGETS openfastcpp openfastcpplib
install(TARGETS openfastcpplib
EXPORT "${CMAKE_PROJECT_NAME}Libraries"
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)

# Build driver if requested
if (BUILD_OPENFAST_CPP_DRIVER)

find_package(yaml-cpp REQUIRED)
add_executable(openfastcpp src/FAST_Prog.cpp)
target_link_libraries(openfastcpp
${YAML_CPP_LIBRARIES}
openfastcpplib
)
target_include_directories(openfastcpp PRIVATE ${YAML_CPP_INCLUDE_DIR})
set_target_properties(openfastcpp PROPERTIES LINKER_LANGUAGE CXX)

if(MPI_COMPILE_FLAGS)
set_target_properties(openfastcpp PROPERTIES
COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
endif(MPI_COMPILE_FLAGS)

if(MPI_LINK_FLAGS)
set_target_properties(openfastcpp PROPERTIES
LINK_FLAGS "${MPI_LINK_FLAGS}")
endif(MPI_LINK_FLAGS)

install(TARGETS openfastcpp
EXPORT "${CMAKE_PROJECT_NAME}Libraries"
RUNTIME DESTINATION lib
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
endif()
24 changes: 16 additions & 8 deletions modules/map/src/mapinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2304,7 +2304,14 @@ MAP_ERROR_CODE push_variable_to_output_list(OutputList* y_list, const int i, dou
size = list_size(&y_list->out_list_ptr);
iter_vartype = (VarTypePtr*)list_get_at(&y_list->out_list_ptr, size-1);
iter_vartype->value = variable_ref;
iter_vartype->name = bformat("%s[%d]", alias, i);
if (i >= 0)
{
iter_vartype->name = bformat("%s[%d]", alias, i);
}
else
{
iter_vartype->name = bformat(alias);
}
iter_vartype->units = bformat("%s", units);

return MAP_SAFE;
Expand All @@ -2325,49 +2332,50 @@ MAP_ERROR_CODE set_output_list(Domain* domain, MAP_InitOutputType_t* io_type, ch
line_iter = (Line*)list_iterator_next(&domain->line);

if (line_iter->options.gx_anchor_pos_flag) {
list_append(&y_list->out_list_ptr, &line_iter->anchor->position_ptr.x);
success = push_variable_to_output_list(y_list, -1, line_iter->anchor->position_ptr.x.value, line_iter->anchor->position_ptr.x.name->data, line_iter->anchor->position_ptr.x.units->data);
io_type->writeOutputHdr_Len++;
io_type->writeOutputUnt_Len++;
};

if (line_iter->options.gy_anchor_pos_flag) {
list_append(&y_list->out_list_ptr, &line_iter->anchor->position_ptr.y);
success = push_variable_to_output_list(y_list, -1, line_iter->anchor->position_ptr.x.value, line_iter->anchor->position_ptr.x.name->data, line_iter->anchor->position_ptr.x.units->data);
io_type->writeOutputHdr_Len++;
io_type->writeOutputUnt_Len++;
};

if (line_iter->options.gz_anchor_pos_flag) {
list_append(&y_list->out_list_ptr, &line_iter->anchor->position_ptr.z);
success = push_variable_to_output_list(y_list, -1, line_iter->anchor->position_ptr.x.value, line_iter->anchor->position_ptr.x.name->data, line_iter->anchor->position_ptr.x.units->data);
io_type->writeOutputHdr_Len++;
io_type->writeOutputUnt_Len++;
};

if (line_iter->options.gx_pos_flag) {
list_append(&y_list->out_list_ptr, &line_iter->fairlead->position_ptr.x);
success = push_variable_to_output_list(y_list, -1, line_iter->fairlead->position_ptr.x.value, line_iter->fairlead->position_ptr.x.name->data, line_iter->fairlead->position_ptr.x.units->data);
io_type->writeOutputHdr_Len++;
io_type->writeOutputUnt_Len++;
};

if (line_iter->options.gy_pos_flag) {
list_append(&y_list->out_list_ptr, &line_iter->fairlead->position_ptr.y);
success = push_variable_to_output_list(y_list, -1, line_iter->fairlead->position_ptr.y.value, line_iter->fairlead->position_ptr.y.name->data, line_iter->fairlead->position_ptr.y.units->data);
io_type->writeOutputHdr_Len++;
io_type->writeOutputUnt_Len++;
};

if (line_iter->options.gz_pos_flag) {
list_append(&y_list->out_list_ptr, &line_iter->fairlead->position_ptr.z);
success = push_variable_to_output_list(y_list, -1, line_iter->fairlead->position_ptr.z.value, line_iter->fairlead->position_ptr.z.name->data, line_iter->fairlead->position_ptr.z.units->data);
io_type->writeOutputHdr_Len++;
io_type->writeOutputUnt_Len++;
};

if (line_iter->options.H_flag) {
list_append(&y_list->out_list_ptr, &line_iter->H);
success = push_variable_to_output_list(y_list, -1, line_iter->H.value, line_iter->H.name->data, line_iter->H.units->data);
io_type->writeOutputHdr_Len++;
io_type->writeOutputUnt_Len++;
};

if (line_iter->options.V_flag) {
list_append(&y_list->out_list_ptr, &line_iter->V);
success = push_variable_to_output_list(y_list, -1, line_iter->V.value, line_iter->V.name->data, line_iter->V.units->data);
io_type->writeOutputHdr_Len++;
io_type->writeOutputUnt_Len++;
};
Expand Down
27 changes: 27 additions & 0 deletions openfast_python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# OpenFAST python readers/writers

> [!CAUTION]
> The `openfast_io` package on PyPI is currently called `octue-openfast` but will soon be renamed.

This package is a python wrapper comprising readers and writers for converting OpenFAST files to/from python objects. It
was originally written for [WEIS](https://github.com/WISDEM/WEIS/tree/77a878d7989b8c1d07d2244135ccd308a193a924/weis/aeroelasticse) and has been ported over to OpenFAST to make it more widely accessible.

## Installation
Run either
```shell
pip install openfast_io
```
or
```shell
poetry add openfast_io
```

### Extra options
[ROSCO](https://github.com/NREL/ROSCO) can be installed as an optional dependency. Run either
```shell
pip install openfast_io[rosco]
```
or
```shell
poetry add -E rosco openfast_io
```
Loading