Skip to content

Commit faa6c00

Browse files
authored
Merge pull request #3238 from andrew-platt/f/AMReX_reader
Add AMReX-based inflow reader to AWAE for FAST.Farm
2 parents 9267c0e + 49760a5 commit faa6c00

File tree

82 files changed

+2097
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2097
-138
lines changed

.github/workflows/automated-dev-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ jobs:
107107
-DBUILD_OPENFAST_LIB_DRIVER:BOOL=ON \
108108
-DBUILD_OPENFAST_CPP_DRIVER:BOOL=ON \
109109
-DBUILD_FASTFARM:BOOL=ON \
110+
-DAMREX_READER=ON \
110111
${GITHUB_WORKSPACE}
111112
- name: Build all
112113
working-directory: ${{github.workspace}}/build
@@ -116,7 +117,7 @@ jobs:
116117
run: |
117118
tar -cvf workspace.tar -C ${{github.workspace}} \
118119
--exclude='*.a' --exclude='*.o' --exclude='build/ftnmods' \
119-
--exclude='.git' --exclude='docs' --exclude='vs-build' \
120+
--exclude='docs' --exclude='vs-build' \
120121
.
121122
- name: Save workspace for other jobs
122123
uses: actions/upload-artifact@v4
@@ -166,6 +167,7 @@ jobs:
166167
-DVARIABLE_TRACKING:BOOL=OFF \
167168
-DBUILD_TESTING:BOOL=ON \
168169
-DCTEST_PLOT_ERRORS:BOOL=ON \
170+
-DAMREX_READER=ON \
169171
${GITHUB_WORKSPACE}
170172
# -DDOUBLE_PRECISION=OFF \
171173
- name: Build all

CMakeLists.txt

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,35 @@ else()
166166
endif()
167167
endif()
168168

169+
#-------------------------------------------------------------------------------
170+
# AMReX reader inclusion in FAST.Farm
171+
#-------------------------------------------------------------------------------
172+
# Included as an external project, cloned to `dependencies` directory
173+
174+
option(AMREX_READER "Include AMReX reader in FAST.Farm" off)
175+
if (AMREX_READER)
176+
if (WIN32)
177+
message(FATAL_ERROR "AMREX_READER option not available on Windows (AMReX incompatible)")
178+
endif()
179+
include(FetchContent)
180+
FetchContent_Declare(
181+
AMReX
182+
GIT_REPOSITORY https://github.com/AMReX-Codes/amrex.git
183+
GIT_TAG 26.02
184+
)
185+
set(AMReX_AMRLEVEL Off CACHE BOOL "" FORCE)
186+
set(AMReX_EXPORT_DYNAMIC Off CACHE BOOL "" FORCE)
187+
set(AMReX_LINEAR_SOLVERS Off CACHE BOOL "" FORCE)
188+
set(AMReX_LINEAR_SOLVERS_EM Off CACHE BOOL "" FORCE)
189+
set(AMReX_LINEAR_SOLVERS_INCLFO Off CACHE BOOL "" FORCE)
190+
set(AMReX_MPI Off CACHE BOOL "" FORCE)
191+
set(AMReX_PARTICLES Off CACHE BOOL "" FORCE)
192+
set(AMReX_FORTRAN On CACHE BOOL "" FORCE)
193+
set(AMReX_FORTRAN_INTERFACES On CACHE BOOL "" FORCE)
194+
set(AMReX_PRECISION DOUBLE CACHE STRING "" FORCE)
195+
FetchContent_MakeAvailable(AMReX)
196+
endif ()
197+
169198
#-------------------------------------------------------------------------------
170199
# Simulink
171200
#-------------------------------------------------------------------------------
@@ -290,9 +319,7 @@ if(BUILD_TESTING)
290319

291320
# unit tests
292321
if(BUILD_UNIT_TESTING)
293-
if(NOT (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Flang"))
294-
add_subdirectory(unit_tests)
295-
endif()
322+
add_subdirectory(unit_tests)
296323
endif()
297324
endif()
298325

@@ -304,4 +331,3 @@ option(BUILD_DOCUMENTATION "Build documentation." OFF)
304331
if(BUILD_DOCUMENTATION)
305332
add_subdirectory(docs)
306333
endif()
307-

docs/source/user/api_change.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ ServoDyn 15 PitDamp(1) 1.4E
7777
ServoDyn 16 PitDamp(2) 1.4E6 PitDamp(2) - Blade 2 pitch damping constant
7878
ServoDyn 17 PitDamp(3) 1.4E6 PitDamp(3) - Blade 3 pitch damping constant *[unused for 2 blades]*
7979
HydroDyn \* HstMod 1 HstMod - Method of computing hydrostatic loads. (0: Up to the still water level. 1: Up to the instantaneous free surface) *[overwrite to 0 when WaveStMod = 0 in SeaState]*
80+
FAST.Farm 35 --- AMBIENT WIND: AMReX MODULE --- [used only for Mod_AmbWind=4]
81+
FAST.Farm 36 WindDirPrefix "inflow/ffboxes" WindDirPrefix - Directory prefix of AMReX wind sub-volumes {0=low-res, 1+=high-res} (quoted string)
82+
FAST.Farm 37 DirStartIndex 00110 DirStartIndex - AMReX sub-volume directory suffix to consider as time=0 (quoted string)
83+
FAST.Farm 38 DT_Low-AMReX 2.0 DT_Low-AMReX - Time step for low-resolution wind data interpolation; will be used as the global FAST.Farm time step (s) [>0.0]
84+
FAST.Farm 39 DT_High-AMReX 1.0 DT_High-AMReX - Time step for high-resolution wind data interpolation (s) [>0.0]
8085
============================================= ======== ==================== ========================================================================================================================================================================================================
8186

8287

docs/source/user/fast.farm/InputFiles.rst

Lines changed: 122 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,18 @@ simulation length set in the OpenFAST primary input file of each wind
8181
turbine in the wind farm.
8282

8383
**Mod_AmbWind** [switch] indicates the ambient wind source. There are
84-
three options: 1) use ambient wind data generated by a high-fidelity
84+
four options: 1) use ambient wind data generated by a high-fidelity
8585
precursor simulation in VTK format **[Mod_AmbWind=1]**, 2) use ambient
8686
wind data as defined by the FAST.Farm interface to the *InflowWind*
87-
module, with one instance of *InflowWind* **[Mod_AmbWind=2]**, or 3) use
87+
module, with one instance of *InflowWind* **[Mod_AmbWind=2]**, 3) use
8888
ambient wind data as defined by the FAST.Farm interface to the
8989
*InflowWind* module, with multiple instances of *InflowWind*
90-
**[Mod_AmbWind=3]**. The distinct Ambient Wind subsections below pertain
91-
to each option.
90+
**[Mod_AmbWind=3]**, or 4) use ambient wind data generated by a
91+
high-fidelity precursor simulation stored in AMReX plot file format
92+
**[Mod_AmbWind=4]**. The distinct Ambient Wind subsections below pertain
93+
to each option. Note that **Mod_AmbWind** = 4 requires FAST.Farm to be
94+
compiled with AMReX support (``-DAMREX_READER=ON`` in CMake, not available when
95+
compiling with Visual Studio).
9296

9397
**Mod_WaveField** [switch] indicates how the wave field should be treated. The
9498
two options are: 1) use individual HydroDyn inputs at each turbine without
@@ -297,6 +301,55 @@ there are spaces in the file or path names, these quotes are required.
297301
See :numref:`FF:AmbWindIfW` for information on the contents of
298302
this file.
299303

304+
.. _FF:Input:AMReX:
305+
306+
Ambient Wind: Precursor in AMReX Format
307+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
308+
309+
The input parameters in this section are only used when **Mod_AmbWind**
310+
= 4, indicating the use of ambient wind from a high-fidelity precursor
311+
simulation stored in `AMReX <https://amrex-codes.github.io>`__ plot file
312+
format. This option requires FAST.Farm to be compiled with the AMReX
313+
library enabled (``-DAMREX_READER=ON`` with CMake). The grid dimensions, origin,
314+
and spatial discretization are read directly from the AMReX plot file
315+
headers and do not need to be specified in the input file.
316+
317+
**WindDirPrefix** [quoted string] specifies the path prefix for the
318+
AMReX wind sub-volume directories. Sub-volume directories follow the
319+
naming convention *<WindDirPrefix>_<sv>_<index>*, where *<sv>* is the
320+
sub-volume number (0 for the low-resolution domain; 1 through
321+
**NumTurbines** for the high-resolution domain of each turbine) and
322+
*<index>* is a zero-padded integer directory index. The path can be
323+
specified relative to the location of the FAST.Farm primary input file
324+
or with an absolute path. It is recommended to use quotes around the
325+
path. See :numref:`FF:AmbWindAMReX` for further details on the expected
326+
directory structure.
327+
328+
**DirStartIndex** [quoted string] specifies the directory index suffix
329+
(e.g., ``"00000"``) corresponding to the simulation start time
330+
:math:`t=0`. The string length determines the zero-padding width applied
331+
to all directory index numbers; the number of leading zeros in
332+
**DirStartIndex** sets the total field width used when constructing
333+
subsequent directory names. FAST.Farm automatically searches for all
334+
available time steps beginning from this index. It is recommended to use
335+
quotes around this value.
336+
337+
**DT_Low-AMReX** [sec] sets the time step of the low-resolution ambient
338+
wind data and the global (driver/glue-code) time step of FAST.Farm. All
339+
FAST.Farm modules are called every **DT_Low-AMReX** seconds, although
340+
OpenFAST and its modules may use a time step that is an integer multiple
341+
smaller than or equal to **DT_Low-AMReX**. The value must match the time
342+
step used when generating the precursor simulation data.
343+
344+
**DT_High-AMReX** [sec] sets the time step of the high-resolution
345+
ambient wind data and **must be an integer multiple smaller than or
346+
equal to DT_Low-AMReX**. It must match the time resolution of the
347+
high-resolution sub-volumes in the precursor data. **DT_Low-AMReX**
348+
should be consistent with the timescales of wake dynamics (e.g., on the
349+
order of seconds), and **DT_High-AMReX** should be sufficient for
350+
accurate aerodynamic load calculations (e.g., on the order of fractions
351+
of a second). Further guidance is given in :numref:`FF:ModGuidance`.
352+
300353
.. _FF:Input:WT:
301354

302355
Wind Turbines
@@ -1056,6 +1109,71 @@ used (**WindType** = 1). When using full-field turbulent wind data in
10561109
*X-Y-Z* offsets of each turbine origin relative to the origin of the
10571110
inertial frame coordinate system.
10581111

1112+
.. _FF:AmbWindAMReX:
1113+
1114+
Ambient Wind Precursor Files in AMReX Plot File Format
1115+
------------------------------------------------------
1116+
1117+
When using **Mod_AmbWind** = 4, the ambient wind data must be
1118+
pre-generated and stored as `AMReX
1119+
<https://amrex-codes.github.io>`__ plot files. AMReX plot files are
1120+
directories containing a ``Header`` file and one or more cell-data files
1121+
storing three-component (*X*, *Y*, *Z*) velocity fields on a structured
1122+
Cartesian grid. FAST.Farm reads the grid dimensions, origin, and
1123+
spacing from the ``Header`` and requires exactly three velocity
1124+
components (``x_velocity``, ``y_velocity``, ``z_velocity`` or equivalent
1125+
names in order).
1126+
1127+
The sub-volume directories must follow the naming convention
1128+
*<WindDirPrefix>_<sv>_<index>*, where:
1129+
1130+
- **WindDirPrefix** is the path prefix specified in the FAST.Farm
1131+
primary input file.
1132+
1133+
- *<sv>* is the sub-volume number: ``0`` for the low-resolution domain
1134+
and ``1`` through **NumTurbines** for the high-resolution domain of
1135+
each wind turbine.
1136+
1137+
- *<index>* is a zero-padded integer index with the same field width as
1138+
**DirStartIndex**. The index for time step :math:`n` is
1139+
:math:`\text{DirStartNum} + n \times \Delta_\text{index}`, where
1140+
:math:`\text{DirStartNum}` is the integer value of **DirStartIndex**
1141+
and :math:`\Delta_\text{index}` is the stride between successive
1142+
directory indices (determined automatically by FAST.Farm by scanning
1143+
the available directories).
1144+
1145+
During initialization, FAST.Farm reads the header of the starting
1146+
sub-volume for each domain (low-resolution sub-volume 0 and each
1147+
high-resolution sub-volume 1 through **NumTurbines**) to obtain the
1148+
grid properties, then calls the directory-discovery routine to confirm
1149+
that a sufficient number of time steps exist and that the grid
1150+
properties are consistent across all time steps. Specifically, FAST.Farm
1151+
verifies:
1152+
1153+
- That at least **NumDT** low-resolution and high-resolution
1154+
directories are available for the simulation duration.
1155+
1156+
- That the grid dimensions, origin, and spacing are identical across
1157+
all time steps for a given sub-volume.
1158+
1159+
- That the grid dimensions are the same for all high-resolution
1160+
sub-volumes (one per turbine).
1161+
1162+
Because the grid properties are determined from the precursor data
1163+
files, the user does not specify low- or high-resolution grid dimensions
1164+
or origins in the FAST.Farm primary input file when using
1165+
**Mod_AmbWind** = 4. The Wind Turbines table also requires only the
1166+
standard four columns (**WT_X**, **WT_Y**, **WT_Z**, **WT_FASTInFile**),
1167+
without the six additional high-resolution grid columns that are needed
1168+
for **Mod_AmbWind** = 2 or 3.
1169+
1170+
.. note::
1171+
1172+
AMReX support is only available when compiling with CMake and must be enabled at
1173+
compile time by passing ``-DAMREX_READER=ON`` during configuration. If FAST.Farm
1174+
is compiled without AMReX support, setting **Mod_AmbWind** = 4 will
1175+
produce a fatal error.
1176+
10591177
.. _FF:Input:OFInput:
10601178

10611179
OpenFAST Input Files

glue-codes/fast-farm/src/FAST_Farm.f90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
PROGRAM FAST_Farm
2727

2828
USE FAST_Farm_Subs
29+
USE amrex_utils
2930

3031
IMPLICIT NONE
3132

@@ -83,6 +84,9 @@ PROGRAM FAST_Farm
8384
call NormStop()
8485
endif
8586

87+
! Initialize AMReX library
88+
call amrex_init(arg_parmparse=.false.)
89+
8690
CALL FAST_ProgStart( Farm_Ver ) ! put this after CheckArgs because CheckArgs assumes we haven't called this routine, yet.
8791

8892
IF ( TRIM(FlagArg) == 'RESTART' ) THEN ! Restart from checkpoint file
@@ -157,6 +161,9 @@ PROGRAM FAST_Farm
157161
!...............................................................................................................................
158162

159163
call FARM_End(farm, ErrStat, ErrMsg)
164+
165+
! Finalize AMReX library
166+
call amrex_finalize()
160167

161168
CALL RunTimes( ProgStrtTime, ProgStrtCPU, SimStrtTime, SimStrtCPU, t )
162169
call NormStop()
@@ -190,6 +197,8 @@ SUBROUTINE CheckError(ErrID,Msg,ErrLocMsg)
190197
END IF
191198

192199
call FARM_End(farm, ErrStat2, ErrMsg2)
200+
! Finalize AMReX library
201+
call amrex_finalize()
193202
call ProgAbort('', TrapErrors=.FALSE., TimeWait=3._ReKi )
194203

195204
END IF

0 commit comments

Comments
 (0)