Matlab Code

matlab logo

The code was written in Matlab 2015b and should be reverse compatible with Matlab version from 2014b and on for CPU computation and is not reverse compatible for GPU computation.

 

Hierarchy

The main script (main.m) is very short and elegant, merely calls the other functions by order.

 

processor_selection & shore_selection functions

GUI for selection of GPU or CPU computation. Shore selection between the three types of shallow seafloor.

 

set_parameters function

All physical, numerical and display parameters are here, there is integral option the export video from the running animation (may burden the evolution calculation). Pay attention that once you've played with p.meshSize (the number of calculation points) you should set p.A correctly in order to have nice waves.

For the GPU case, some parameters run over by set_gpu_parameters function.

 

generate_seafloor function

The step-like seafloor is the basis to our FEM computation. This function just build seafloor matrix (no need to touch).

 

generate_wave_spectrum function

This function generate initial wave spectrum by the wind parameters. All this wave spectrum takes place in the far depth so the displayed waves are just propagation of these (otherwise we would get a teacup storm and not breaking waves).

 

initial_surface function

Just builds flat surface for initial conditions with the initial wave spectrum far away.

 

loop function

Calculates the time evolution of the system and display in an infinite loop. Contains a skip button that skip 10 seconds and stop button in order to exit from the animation.

 

figdesign, blue_colormap & shock_boundary functions

Auxiliary functions for the loop, contain figure design, colormap and first shock display separation.

 

Download Code

The functions are archived in tar and zip archives for your convenient: