-
Notifications
You must be signed in to change notification settings - Fork 457
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
Use dt_out when storing OpenFAST outputs in Python interface #1211
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DT_Out is needed to determine the frequency at which results should be captured from FAST_Update in the programs that use openfast-library. This change exposes the DT_out by adding it the arguments of FAST_Sizes. The corresponding function prototype was updated in FAST_Library.h.
For long simulations openfast_library.py would allocate a large array to hold output values for every step based on DT. This array could consume a significant amount of memory and was inconsistent with the data stored in output files which is based on DT_Out. This commit bases the output array size on DT_Out and changes the data collection to match, which can significantly reduce memory usage. In addition, the output_values array is passed directory to FAST_Update to reduce copying data. Lastly, the channel name processing is moved to fast_init to avoid a memory leak
The C++ interface to openfast-library was updated to match the changes to openfast_library.py - basing output on DT_Out instead of DT. Also, the output_array variable was removed and output_values changed to a vector of vectors so the memory will be freed when FastLibAPI is destroyed. This change also removes the copying of data between arrays.
Updates FAST_SFunc.c for the new FAST_Sizes function signature which exposes DT_Out.
This change was requested to so WEIS, which uses this library, doesn't have to change.
Class member was renamed for consistency with openfast_library.py.
Renaming the class member channel_names to output_channel_names created a conflict with a class function prototype which was designed to return a string of channel names. To make FastLibAPI consistent with openfast_library.py, this commit changes output_channel_names to be a vector of strings which is populated by the fast_init method.
Will the addition of the |
The Simulink interface is updated here, and the SOWFA / AMR-Wind interface aren't changed. Those use the |
rafmudaf
approved these changes
Aug 16, 2022
rafmudaf
changed the title
Bug/pythonlib
Use dt_out when storing OpenFAST outputs in Python interface
Aug 16, 2022
Is there any reason to wait on merging this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request is ready for merging.
All regression tests are passing and development is complete. No additional documentation is required.
Feature or improvement description
This pull request resolves an issue where the openfast_library.py file was allocating too much memory on large simulations.
Related issue, if one exists
None
Impacted areas of the software
Additional supporting information
The existing versions of openfast_library.py and FastLibAPI allocate an output array with a size NUM_OUTPUTS*(T_MAX/DT). This size is inconsistent with the output files which contain data written every DT_OUT seconds. The code changes in this PR cause the output data to be collected on the DT_OUT interval which reduces memory usage and matches current output files. DT_OUT was exposed to these libraries by adding it to the FAST_Sizes arguments which required changes to the Fortran, C, C++, Python, and Simulink libraries.
These changes also resolve a potential memory leak in FastLibAPI where the output data array was not freed by the parent class destructor. This was fixed by changing the output array to a vector of vectors which is automatically destroyed.
Test results, if applicable
Developer testing showed a reduction is memory use due to allocation of smaller output arrays.