This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

(copied from https://github.com/othneildrew/Best-README-Template/blob/main/LICENSE.txt)

---------------------------------------------------------------------------------------------

This remainder of this document gives a bird's eye view of the morphodynamic DUNE model. The river version is described in Van der Sande et al. (2025), Geomorphology. The tidal version is described in Van der Sande (2024), chapter 5 (https://doi.org/10.3990/1.9789036560320). The DUNE model contains both versions.

In short: this morphodynamic model covers a 2DV(ertical) domain with rigid lid at the surface, longitudinal periodicity (i.e., what flows out on the right flows in on the left and vice versa). Flow is described by RANS with k-omega turbulence closure and is solved within OpenFOAM. Bed shear stress is extracted to calculate (bed-load) sediment transport and bed evolution. Although it was developed for DUNEs (primary bedforms), I suppose the model could represent other morphodynamic entities in the 2DV plane as well. 

For this code to run, you'll need (this is unfortunately a noncomprehensive list of required software):
- OpenFOAM (I've used v2206 in the development of the model)
- gcc, I have version 11.3.0 (this is the C++ compiler)
- xtensor

Future releases should come with a .yml file. 

To run the model, you should navigate to the folder DUNE and type 
./runAll_script.sh
in the command window and press enter. This bash file compiles the code and runs the model. 

The model's code is mainly located in DUNE/MAIN.cpp. Related functions are located in the folder FOAM_funcs_wesselut. 

The structure of MAIN.cpp is as follows:
1-60: preamble (including some functions that could've been moved elsewhere)
61-105: defines what the simulation will be about
106-210: initializing variabiles
211: start simulation, passing the for-loop Nt times
221-318: the first timestep is treated somewhat differently. Here, forcing terms are determined (and, depending on settings, kept constant or not). 
319-348: runs OpenFOAM to obtain a flow result after initial timestep. 
352-362: to save hydrodynamic data (if you desire, note that this can quickly take up quite some storage). Data is stored in the folder hydDat. 
365-480: obtain bed-shear stress from OpenFOAM, calculate sediment transport
482-593: prepare linear system and solve for new timestep (line 591) 
597-649: extract variables and save them to their respective files. 
652-665: adapt depth (depending on setting), only in the river case. This allows the mean water depth to change as a consequence of DUNE formation.  
683-697: moves morphDat and hydDat folders to their respective folders and names them 'morphDat#', with # a consecutive number. 

Within MAIN.cpp, there is a large number of modeling choices that you can make. These come in the form of Booleans (true/false). Some of these options are: 
- river or sea (unidirectional or bidirectional flow). If sea = true, river should be false. 
- momForcing or velocityForcing: momForcing imposes a momentum source, velocityForcing finds a momentum source such that a domain-averaged velocity is satisfied. 
- initPerturbedBed is an initially slightly non-flat bed. If false, you should provide an initial topography. 

Environmental variables can be set within the file Vars.cpp. 
