Skip to content

File Testing.cu

FileList > src > Testing.cu

Go to the source code of this file

  • #include "Testing.h"

Public Functions

Type Name
bool CPUGPUtest (Param XParam, Model< T > XModel, Model< T > XModel_g)
void CompareCPUvsGPU (Param XParam, Model< T > XModel, Model< T > XModel_g, std::vector< std::string > varlist, bool checkhalo)
Compares the Variables in a CPU model and a GPU models This function is quite useful when checking both are identical enough one needs to provide a list (vector<string>) of variable to check.
template void CompareCPUvsGPU< double > (Param XParam, Model< double > XModel, Model< double > XModel_g, std::vector< std::string > varlist, bool checkhalo)
template void CompareCPUvsGPU< float > (Param XParam, Model< float > XModel, Model< float > XModel_g, std::vector< std::string > varlist, bool checkhalo)
bool GaussianHumptest (T zsnit, int gpu, bool compare)
Gaussian hump propagation test.
template bool GaussianHumptest< double > (double zsnit, int gpu, bool compare)
template bool GaussianHumptest< float > (float zsnit, int gpu, bool compare)
bool LakeAtRest (Param XParam, Model< T > XModel)
Test the lake at rest condition This function simulates the first predictive step and check whether the lake at rest is preserved otherwise it prints out to screen the cells (and neighbour) where the test fails.
Forcing< float > MakValleyBathy (Param XParam, T slope, bool bottop, bool flip)
Creates a valley bathymetry This function creates a valley bathymetry with a given slope and center It also adds a wall around the domain to avoid boundary effects.
bool MassConserveSteepSlope (T zsnit, int gpu)
River inflow mass conservation test on steep slope.
template bool MassConserveSteepSlope< double > (double zsnit, int gpu)
template bool MassConserveSteepSlope< float > (float zsnit, int gpu)
bool Rainlossestest (T zsinit, int gpu, float alpha)
Test the Initial and Continuous losses implementation This function tests the Initial Losses and Continuous Losses implementation a plain domain, under constant rain. The function creates its own model setup and mesh independantly to what the user inputs. This starts with a initial water level (zsinit=0.0 is dry) and runs for 1s comparing results every 0.1s (that is approx 20 steps)
bool Raintest (T zsnit, int gpu, float alpha, int engine)
Test the rain input and mass conservation This function tests the mass conservation of the spacial injection (used to model rain on grid) The function creates its own model setup and mesh independantly to what the user inputs. This starts with a initial water level (zsnit=0.0 is dry) and runs for 0.1s before comparing results with zsnit=0.1 that is approx 20 steps.
bool Raintestinput (int gpu)
Test the rain input options This function tests the different inputs for rain forcing. This test is based on the paper Aureli2020, the 3 slopes test with regional rain. The experiment has been presented in Iwagaki1955. The first test compares a time varying rain input using a uniform time serie forcing and a time varying 2D field (with same value). The second test check the 3D rain forcing (comparing it to expected values).
std::vector< float > Raintestmap (int gpu, int dimf, T zinit)
Test the rain input options and return the flux at the bottom of the slope This function return the flux at the bottom of the 3 part slope for different types of rain forcings using the test case based on Iwagaki1955.
template std::vector< float > Raintestmap< double > (int gpu, int dimf, double Zsinit)
template std::vector< float > Raintestmap< float > (int gpu, int dimf, float Zsinit)
bool RiverOnBoundary (Param XParam, T slope, int Dir, int Bound_type)
bool RiverVolumeAdapt (Param XParam, T maxslope)
bool RiverVolumeAdapt (Param XParam, T slope, bool bottop, bool flip)
Simulate a river flowing in a steep valley and heck the Volume conservation.
bool Rivertest (T zsnit, int gpu)
River inflow mass conservation test.
template bool Rivertest< double > (double zsnit, int gpu)
template bool Rivertest< float > (float zsnit, int gpu)
int TestAIObnd (Param XParam, Model< T > XModel, Model< T > XModel_g, bool bottop, bool flip, bool withaoi)
Test the aoibnd option of the model This function tests the aoibnd option of the model on a valley domain with a small amount of water The function creates its own model setup and mesh independantly to what the user inputs. This starts with a initial water level (zsinit=0.0 is dry) and runs for 20s.
void TestFirsthalfstep (Param XParam, Forcing< float > XForcing, Model< T > XModel, Model< T > XModel_g)
Test the first half step of the model This function tests the first half step of the model on a sloping domain with a small amount of water The function creates its own model setup and mesh independantly to what the user inputs. This starts with a initial water level (zsinit=0.0 is dry) and runs for 1s comparing results every 0.1s.
bool TestFlexibleOutputTimes (int gpu, T ref, int scenario)
Test the reading of flexible output times.
int TestGradientSpeed (Param XParam, Model< T > XModel, Model< T > XModel_g)
Test the speed of different gradient functions This function fill an array with random values (0 - 1)
bool TestHaloSpeed (Param XParam, Model< T > XModel, Model< T > XModel_g)
Test the speed of different halo filling functions This function test the speed and accuracy of a new gradient function gradient are only calculated for zb but assigned to different gradient variable for storage.
int TestInstability (Param XParam, Model< T > XModel, Model< T > XModel_g)
Test the stability of the model This function tests the stability of the model on a sloping domain with a small amount of water The function creates its own model setup and mesh independantly to what the user inputs. This starts with a initial water level (zsinit=0.0 is dry) and runs for 1s comparing results every 0.1s.
bool TestMultiBathyRough (int gpu, T ref, int scenario)
Test the reading of multiple bathymetry and roughness files.
int TestPinMem (Param XParam, Model< T > XModel, Model< T > XModel_g)
Test the pin memory allocation and transfer between CPU and GPU This function allocates a pinned memory array on the CPU, fills it with values, transfers it to the GPU, modifies it there, and transfers it back to the CPU. It then checks that the values have been correctly modified.
template int TestPinMem< double > (Param XParam, Model< double > XModel, Model< double > XModel_g)
template int TestPinMem< float > (Param XParam, Model< float > XModel, Model< float > XModel_g)
bool Testing (Param XParam, Forcing< float > XForcing, Model< T > XModel, Model< T > XModel_g)
Wrapping function for all the inbuilt test This function is the entry point to other function below.
template bool Testing< double > (Param XParam, Forcing< float > XForcing, Model< double > XModel, Model< double > XModel_g)
template bool Testing< float > (Param XParam, Forcing< float > XForcing, Model< float > XModel, Model< float > XModel_g)
void TestingOutput (Param XParam, Model< T > XModel)
OUTDATED ?Test the output functions of the model OUTDATED? This function tests the output functions of the model by running a simple simulation and writing the output to a netcdf file.
template void TestingOutput< double > (Param XParam, Model< double > XModel)
template void TestingOutput< float > (Param XParam, Model< float > XModel)
void Testzbinit (Param XParam, Forcing< float > XForcing, Model< T > XModel, Model< T > XModel_g)
Test the zbinit option of the model This function tests the zbinit option of the model on a sloping domain with a small amount of water The function creates its own model setup and mesh independantly to what the user inputs. This starts with a initial water level (zsinit=0.0 is dry) and runs for 1s comparing results every 0.1s.
T ThackerBathy (T x, T y, T L, T D)
create a parabolic bassin
bool ThackerLakeAtRest (Param XParam, T zsinit)
Simulate the Lake-at-rest in a parabolic bassin.
template bool ThackerLakeAtRest< double > (Param XParam, double zsinit)
template bool ThackerLakeAtRest< float > (Param XParam, float zsinit)
T ValleyBathy (T x, T y, T slope, T center)
create V shape Valley basin
bool ZoneOutputTest (int nzones, T zsinit)
Test the zoned output This function test the zoned output for a basic configuration.
template bool ZoneOutputTest< double > (int nzones, double zsinit)
template bool ZoneOutputTest< float > (int nzones, float zsinit)
void alloc_init2Darray (float ** arr, int NX, int NY)
Allocates and initializes a 2D array This function allocates and fills a 2D array with zero values.
void copyBlockinfo2var (Param XParam, BlockP< T > XBlock, int * blkinfo, T * z)
Copies block info to an output variable This function copies block info to an output variable This function is somewhat useful when checking bugs in the mesh refinement or coarsening one needs to provide a pointer(z) allocated on the CPU to store the clockinfo This fonction only works on CPU.
template void copyBlockinfo2var< double > (Param XParam, BlockP< double > XBlock, int * blkinfo, double * z)
template void copyBlockinfo2var< float > (Param XParam, BlockP< float > XBlock, int * blkinfo, float * z)
void copyID2var (Param XParam, BlockP< T > XBlock, T * z)
Copies block ID to an output variable This function copies block info to an output variable This function is somewhat useful when checking bugs in the mesh refinement or coarsening one needs to provide a pointer(z) allocated on the CPU to store the clockinfo This fonction only works on CPU.
template void copyID2var< double > (Param XParam, BlockP< double > XBlock, double * z)
template void copyID2var< float > (Param XParam, BlockP< float > XBlock, float * z)
void diffArray (Param XParam, BlockP< T > XBlock, std::string varname, bool checkhalo, T * cpu, T * gpu, T * dummy, T * out)
void diffSource (Param XParam, BlockP< T > XBlock, T * Fqux, T * Su, T * output)
Calculate The source term of the equation This function Calculate The source term of the equation. This function is quite useful when checking for Lake-at-Rest states This function requires an outputCPU pointers to save the result of the calculation.
void diffdh (Param XParam, BlockP< T > XBlock, T * input, T * output, T * shuffle)
Calculate The difference between adjacent cells in an array This function Calculates The difference in left and right flux terms. This function is quite useful when checking for Lake-at-Rest states This function requires a preallocated output and a shuffle (right side term) CPU pointers to save the result of teh calculation.
void fillgauss (Param XParam, BlockP< T > XBlock, T amp, T * z)
Fill an array with a gaussian bump This function fill an array with a gaussian bump.
template void fillgauss< double > (Param XParam, BlockP< double > XBlock, double amp, double * z)
template void fillgauss< float > (Param XParam, BlockP< float > XBlock, float amp, float * z)
void fillrandom (Param XParam, BlockP< T > XBlock, T * z)
Fill an array with random values This function fill an array with random values (0 - 1)
template void fillrandom< double > (Param XParam, BlockP< double > XBlock, double * z)
template void fillrandom< float > (Param XParam, BlockP< float > XBlock, float * z)
void init3Darray (float *** arr, int rows, int cols, int depths)
Initializes a 3D array This function fill a 3D array with zero values.
bool reductiontest (Param XParam, Model< T > XModel, Model< T > XModel_g)
Reduction test Test the algorithm for reducing the global time step on the user grid layout.
template bool reductiontest< double > (Param XParam, Model< double > XModel, Model< double > XModel_g)
template bool reductiontest< float > (Param XParam, Model< float > XModel, Model< float > XModel_g)
void testButtingerX (Param XParam, int ib, int ix, int iy, Model< T > XModel)
Test the Buttinger scheme in X direction This function goes through the Buttinger scheme but instead of the normal output just prints all teh usefull values This function is/was used in the lake-at-rest verification.
bool testboundaries (Param XParam, T maxslope)
void testkurganovX (Param XParam, int ib, int ix, int iy, Model< T > XModel)
Test the Kurganov scheme in X direction This function goes through the Kurganov scheme but instead of the normal output just prints all teh usefull values This function is/was used in the lake-at-rest verification See also: void testButtingerX(Param XParam, int ib, int ix, int iy, Model<T> XModel)
__global__ void vectoroffsetGPU (int nx, T offset, T * z)
A simple kernel to add an offset to a vector This is used to test the pin memory allocation and transfer between CPU and GPU.

Public Functions Documentation

function CPUGPUtest

template<class T>
bool CPUGPUtest (
    Param XParam,
    Model < T > XModel,
    Model < T > XModel_g
) 

function CompareCPUvsGPU

Compares the Variables in a CPU model and a GPU models This function is quite useful when checking both are identical enough one needs to provide a list (vector<string>) of variable to check.

template<class T>
void CompareCPUvsGPU (
    Param XParam,
    Model < T > XModel,
    Model < T > XModel_g,
    std::vector< std::string > varlist,
    bool checkhalo
) 

!

Parameters:

  • XParam Model parameters
  • XModel Model structure (CPU)
  • XModel_g Model structure (GPU)
  • varlist List of variable names to check (as in OutputVarMap)
  • checkhalo true if halo cells should be checked, false otherwise

function CompareCPUvsGPU< double >

template void CompareCPUvsGPU< double > (
    Param XParam,
    Model < double > XModel,
    Model < double > XModel_g,
    std::vector< std::string > varlist,
    bool checkhalo
) 

function CompareCPUvsGPU< float >

template void CompareCPUvsGPU< float > (
    Param XParam,
    Model < float > XModel,
    Model < float > XModel_g,
    std::vector< std::string > varlist,
    bool checkhalo
) 

function GaussianHumptest

Gaussian hump propagation test.

template<class T>
bool GaussianHumptest (
    T zsnit,
    int gpu,
    bool compare
) 

!

This function tests the full hydrodynamics model and compares the results with pre-conmputed (Hard wired) values The function creates it own model setup and mesh independantly to what the user might want to do The setup consist of a centrally located gaussian hump radiating away The test stops at an arbitrary time to compare with 8 values extracted from a identical run in basilisk This function also compares the result of the GPU and CPU code (until they diverge)

Parameters:

  • zsnit Initial water surface elevation at the centre of the domain
  • gpu GPU device number to use (-1 for CPU only)
  • compare If true, compare GPU and CPU results (GPU required)

Returns:

true if the test passed (results within 1e-6 of reference values)


function GaussianHumptest< double >

template bool GaussianHumptest< double > (
    double zsnit,
    int gpu,
    bool compare
) 

function GaussianHumptest< float >

template bool GaussianHumptest< float > (
    float zsnit,
    int gpu,
    bool compare
) 

function LakeAtRest

Test the lake at rest condition This function simulates the first predictive step and check whether the lake at rest is preserved otherwise it prints out to screen the cells (and neighbour) where the test fails.

template<class T>
bool LakeAtRest (
    Param XParam,
    Model < T > XModel
) 

!

The function inherits the adaptation set in XParam so needs to be rerun to accnout for the different scenarios: * uniform level * flow from coasrse to fine * flow from fine to coarse This is done in the higher level wrapping function

Parameters:

Returns:

true if test passed


function MakValleyBathy

Creates a valley bathymetry This function creates a valley bathymetry with a given slope and center It also adds a wall around the domain to avoid boundary effects.

template<class T>
Forcing < float > MakValleyBathy (
    Param XParam,
    T slope,
    bool bottop,
    bool flip
) 

Parameters:

  • XParam Model parameters (only used to set the mesh size)
  • slope Slope of the valley
  • bottop true if the valley is oriented in the y direction (i.e. bottom/top boundaries), false if in the x direction (i.e. left/right boundaries)
  • flip true if the valley is oriented towards top or right, false if towards bottom or left

Returns:

A Forcing structure containing the bathymetry


function MassConserveSteepSlope

River inflow mass conservation test on steep slope.

template<class T>
bool MassConserveSteepSlope (
    T zsnit,
    int gpu
) 

!

This function tests the mass conservation of the vertical injection (used for rivers) The function creates it own model setup and mesh independantly to what the user might want to do This starts with a initial water level (zsnit=0 is dry) and runs for 0.1s before comparing results with zsnit=0.1 that is approx 20 steps

Parameters:

  • zsnit Initial water surface elevation at the centre of the domain
  • gpu GPU device number to use (-1 for CPU only)

Returns:

true if the test passed (mass conservation within 5%)


function MassConserveSteepSlope< double >

template bool MassConserveSteepSlope< double > (
    double zsnit,
    int gpu
) 

function MassConserveSteepSlope< float >

template bool MassConserveSteepSlope< float > (
    float zsnit,
    int gpu
) 

function Rainlossestest

Test the Initial and Continuous losses implementation This function tests the Initial Losses and Continuous Losses implementation a plain domain, under constant rain. The function creates its own model setup and mesh independantly to what the user inputs. This starts with a initial water level (zsinit=0.0 is dry) and runs for 1s comparing results every 0.1s (that is approx 20 steps)

template<class T>
bool Rainlossestest (
    T zsinit,
    int gpu,
    float alpha
) 

!

Parameters:

  • zsinit Initial water level
  • gpu GPU device to use (or -1 for CPU)
  • alpha Tolerance for the test (relative error)

Returns:

true if test passed


function Raintest

Test the rain input and mass conservation This function tests the mass conservation of the spacial injection (used to model rain on grid) The function creates its own model setup and mesh independantly to what the user inputs. This starts with a initial water level (zsnit=0.0 is dry) and runs for 0.1s before comparing results with zsnit=0.1 that is approx 20 steps.

template<class T>
bool Raintest (
    T zsnit,
    int gpu,
    float alpha,
    int engine
) 

!

Parameters:

  • zsnit Initial water level
  • gpu GPU device to use (or -1 for CPU)
  • alpha Slope of the bathymetry in %
  • engine Engine to use (0=non-hydrostatic, 1=hydrostatic)

Returns:

true if test passed


function Raintestinput

Test the rain input options This function tests the different inputs for rain forcing. This test is based on the paper Aureli2020, the 3 slopes test with regional rain. The experiment has been presented in Iwagaki1955. The first test compares a time varying rain input using a uniform time serie forcing and a time varying 2D field (with same value). The second test check the 3D rain forcing (comparing it to expected values).

bool Raintestinput (
    int gpu
) 

!

Parameters:

  • gpu GPU device to use (or -1 for CPU)

Returns:

true if test passed


function Raintestmap

Test the rain input options and return the flux at the bottom of the slope This function return the flux at the bottom of the 3 part slope for different types of rain forcings using the test case based on Iwagaki1955.

template<class T>
std::vector< float > Raintestmap (
    int gpu,
    int dimf,
    T zinit
) 

! \fnstdvector<float> Raintestmap(int gpu, int dimf, T zinit)

Parameters:

  • gpu GPU device to use (or -1 for CPU)
  • dimf Dimension of the rain forcing (1=uniform, 3=2
  • zinit Initial water level

Returns:

vector of flux at the bottom of the slope


function Raintestmap< double >

template std::vector< float > Raintestmap< double > (
    int gpu,
    int dimf,
    double Zsinit
) 

function Raintestmap< float >

template std::vector< float > Raintestmap< float > (
    int gpu,
    int dimf,
    float Zsinit
) 

function RiverOnBoundary

template<class T>
bool RiverOnBoundary (
    Param XParam,
    T slope,
    int Dir,
    int Bound_type
) 

function RiverVolumeAdapt

template<class T>
bool RiverVolumeAdapt (
    Param XParam,
    T maxslope
) 

function RiverVolumeAdapt

Simulate a river flowing in a steep valley and heck the Volume conservation.

template<class T>
bool RiverVolumeAdapt (
    Param XParam,
    T slope,
    bool bottop,
    bool flip
) 

!

This function creates a dry steep valley topography to a given level and run the model for a while and checks that the Volume matches the theory.

The function can test the water volume for 4 scenario each time: * left to right: bottop=false & flip=true; * right to left: bottop=false & flip=false; * bottom to top: bottop=true & flip=true; * top to bottom: bottop=true & flip=false;

The function inherits the adaptation set in XParam so needs to be rerun to account for the different scenarios: * uniform level * flow from coarse to fine * flow from fine to coarse This is done in the higher level wrapping function

Parameters:

  • XParam Model parameters
  • slope slope of the valley sides
  • bottop if true the river flows bottom to top, if false left to right
  • flip if true the river flows right to left or top to bottom, if false left to right or bottom to top

Returns:

true if test passed


function Rivertest

River inflow mass conservation test.

template<class T>
bool Rivertest (
    T zsnit,
    int gpu
) 

!

This function tests the mass conservation of the vertical injection (used for rivers) The function creates it own model setup and mesh independantly to what the user might want to do This starts with a initial water level (zsnit=0 is dry) and runs for 0.1s before comparing results with zsnit=0.1 that is approx 20 steps

Parameters:

  • zsnit Initial water surface elevation at the centre of the domain
  • gpu GPU device number to use (-1 for CPU only)

Returns:

true if the test is successful (mass is conserved within 0.1% of the theoretical value)


function Rivertest< double >

template bool Rivertest< double > (
    double zsnit,
    int gpu
) 

function Rivertest< float >

template bool Rivertest< float > (
    float zsnit,
    int gpu
) 

function TestAIObnd

Test the aoibnd option of the model This function tests the aoibnd option of the model on a valley domain with a small amount of water The function creates its own model setup and mesh independantly to what the user inputs. This starts with a initial water level (zsinit=0.0 is dry) and runs for 20s.

template<class T>
int TestAIObnd (
    Param XParam,
    Model < T > XModel,
    Model < T > XModel_g,
    bool bottop,
    bool flip,
    bool withaoi
) 

Parameters:

  • XParam Model parameters
  • XModel Model structure (CPU)
  • XModel_g Model structure (GPU)
  • bottop true if the boundary condition to test is bottom/top, false for left/right
  • flip true if the boundary condition to test is top or right, false for bottom or left
  • withaoi true if the AOI is to be used, false otherwise

Returns:

1 if the test passed (i.e. the model runs without crashing and gives a reasonable result), 0 otherwise


function TestFirsthalfstep

Test the first half step of the model This function tests the first half step of the model on a sloping domain with a small amount of water The function creates its own model setup and mesh independantly to what the user inputs. This starts with a initial water level (zsinit=0.0 is dry) and runs for 1s comparing results every 0.1s.

template<class T>
void TestFirsthalfstep (
    Param XParam,
    Forcing < float > XForcing,
    Model < T > XModel,
    Model < T > XModel_g
) 

Parameters:

  • XParam Model parameters
  • XModel Model structure (CPU)
  • XModel_g Model structure (GPU)

function TestFlexibleOutputTimes

Test the reading of flexible output times.

template<class T>
bool TestFlexibleOutputTimes (
    int gpu,
    T ref,
    int scenario
) 

This function creates a case set-up with a param file, read it. It tests the reading and default values used for times outputs. It checks the vectors for time outputs.

Parameters:

  • gpu GPU to use (-1 for CPU only)
  • ref Reference elevation for the bathymetry files
  • scenario Scenario to test (not used here but could be used to test different input cases)

Returns:

true if test passed (i.e. the model runs without crashing and gives a reasonable result)


function TestGradientSpeed

Test the speed of different gradient functions This function fill an array with random values (0 - 1)

template<class T>
int TestGradientSpeed (
    Param XParam,
    Model < T > XModel,
    Model < T > XModel_g
) 

!

This function test the spped and accuracy of a new gradient function gradient are only calculated for zb but assigned to different gradient variable for storage

Parameters:

  • XParam Model parameters
  • XModel Model structure (CPU)
  • XModel_g Model structure (GPU)

Returns:

1 if test passed


function TestHaloSpeed

Test the speed of different halo filling functions This function test the speed and accuracy of a new gradient function gradient are only calculated for zb but assigned to different gradient variable for storage.

template<class T>
bool TestHaloSpeed (
    Param XParam,
    Model < T > XModel,
    Model < T > XModel_g
) 

!

Parameters:

  • XParam Model parameters
  • XModel Model structure (CPU)
  • XModel_g Model structure (GPU)

Returns:

true if test passed


function TestInstability

Test the stability of the model This function tests the stability of the model on a sloping domain with a small amount of water The function creates its own model setup and mesh independantly to what the user inputs. This starts with a initial water level (zsinit=0.0 is dry) and runs for 1s comparing results every 0.1s.

template<class T>
int TestInstability (
    Param XParam,
    Model < T > XModel,
    Model < T > XModel_g
) 

Parameters:

  • XParam Model parameters
  • XModel Model structure (CPU)
  • XModel_g Model structure (GPU)

Returns:

0 if test failed (i.e. unstable), 1 if test passed


function TestMultiBathyRough

Test the reading of multiple bathymetry and roughness files.

template<class T>
bool TestMultiBathyRough (
    int gpu,
    T ref,
    int scenario
) 

!

This function creates bathy and roughtness files and tests their reading (and interpolation) The objectif is particularly to test multi bathy/roughness inputs and value/file input.

Parameters:

  • gpu GPU to use (-1 for CPU only)
  • ref Reference elevation for the bathymetry files
  • scenario Scenario to test (0: R1 in the middle of the domain, 1: R1 covering the whole domain)

Returns:

true if test passed (i.e. the model runs without crashing and gives a reasonable result)


function TestPinMem

Test the pin memory allocation and transfer between CPU and GPU This function allocates a pinned memory array on the CPU, fills it with values, transfers it to the GPU, modifies it there, and transfers it back to the CPU. It then checks that the values have been correctly modified.

template<class T>
int TestPinMem (
    Param XParam,
    Model < T > XModel,
    Model < T > XModel_g
) 

Parameters:

  • XParam Model parameters (only GPUDEVICE is used)
  • XModel Model structure (CPU)
  • XModel_g Model structure (GPU)

Returns:

1 if the test passed (i.e. the values are as expected), 0 otherwise


function TestPinMem< double >

template int TestPinMem< double > (
    Param XParam,
    Model < double > XModel,
    Model < double > XModel_g
) 

function TestPinMem< float >

template int TestPinMem< float > (
    Param XParam,
    Model < float > XModel,
    Model < float > XModel_g
) 

function Testing

Wrapping function for all the inbuilt test This function is the entry point to other function below.

template<class T>
bool Testing (
    Param XParam,
    Forcing < float > XForcing,
    Model < T > XModel,
    Model < T > XModel_g
) 

Test 0 is a gausian hump propagating on a flat uniorm cartesian mesh (both GPU and CPU version tested) Test 1 is vertical discharge on a flat uniorm cartesian mesh (GPU or CPU version) Test 2 Gaussian wave on Cartesian grid (same as test 0): CPU vs GPU (GPU required) Test 3 Test Reduction algorithm Test 4 Boundary condition test Test 5 Lake at rest test for Ardusse/kurganov reconstruction/scheme Test 6 Mass conservation on a slope Test 7 Mass conservation with rain fall on grid Test 8 Rain Map forcing (comparison map and Time Serie and test case with slope and non-uniform rain map) Test 9 Zoned output (test zoned outputs with adaptative grid) Test 10 Initial Loss / Continuous Loss on a slope, under uniform rain Test 11 Wet/dry Instability test with Conserve Elevation Test 12 Calendar time to second conversion Test 13 Multi bathy and roughness map input Test 14 Test AOI bnds aswall to start with Test 15 Flexible times reading

Test 99 Run all the test with test number < 99.

The following test are not independant, they are tools to check or debug a personnal case Test 998 Compare resuts between the CPU and GPU Flow functions (GPU required) Test 999 Run the main loop and engine in debug mode

Parameters:

  • XParam Simulation parameters
  • XForcing Forcing data structure
  • XModel Host model data structure
  • XModel_g Device model data structure

Returns:

true if all the tests passed


function Testing< double >

template bool Testing< double > (
    Param XParam,
    Forcing < float > XForcing,
    Model < double > XModel,
    Model < double > XModel_g
) 

function Testing< float >

template bool Testing< float > (
    Param XParam,
    Forcing < float > XForcing,
    Model < float > XModel,
    Model < float > XModel_g
) 

function TestingOutput

OUTDATED ?Test the output functions of the model OUTDATED? This function tests the output functions of the model by running a simple simulation and writing the output to a netcdf file.

template<class T>
void TestingOutput (
    Param XParam,
    Model < T > XModel
) 

!

Parameters:

  • XParam Model parameters
  • XModel Model structure (CPU)

function TestingOutput< double >

template void TestingOutput< double > (
    Param XParam,
    Model < double > XModel
) 

function TestingOutput< float >

template void TestingOutput< float > (
    Param XParam,
    Model < float > XModel
) 

function Testzbinit

Test the zbinit option of the model This function tests the zbinit option of the model on a sloping domain with a small amount of water The function creates its own model setup and mesh independantly to what the user inputs. This starts with a initial water level (zsinit=0.0 is dry) and runs for 1s comparing results every 0.1s.

template<class T>
void Testzbinit (
    Param XParam,
    Forcing < float > XForcing,
    Model < T > XModel,
    Model < T > XModel_g
) 

Parameters:

  • XParam Model parameters
  • XModel Model structure (CPU)
  • XModel_g Model structure (GPU)

function ThackerBathy

create a parabolic bassin

template<class T>
T ThackerBathy (
    T x,
    T y,
    T L,
    T D
) 

!

This function creates a parabolic bassin. The function returns a single value of the bassin

Borrowed from Buttinger et al. 2019.

Reference

Buttinger-Kreuzhuber, A., Horváth, Z., Noelle, S., Blöschl, G., and Waser, J.: A fast second-order shallow water scheme on two-dimensional structured grids over abrupt topography, Advances in water resources, 127, 89–108, 2019.

Parameters:

  • x x coordinate
  • y y coordinate
  • L characteristic length scale of the bassin
  • D characteristic depth of the bassin

Returns:

the depth of the basin at point (x,y)


function ThackerLakeAtRest

Simulate the Lake-at-rest in a parabolic bassin.

template<class T>
bool ThackerLakeAtRest (
    Param XParam,
    T zsinit
) 

This function creates a parabolic bassin filled to a given level and run the modle for a while and checks that the velocities in the lake remain very small thus verifying the well-balancedness of teh engine and the Lake-at-rest condition.

Borrowed from Buttinger et al. 2019.

Reference

Buttinger-Kreuzhuber, A., Horváth, Z., Noelle, S., Blöschl, G., and Waser, J.: A fast second-order shallow water scheme on two-dimensional structured grids over abrupt topography, Advances in water resources, 127, 89–108, 2019.

Parameters:

  • XParam Model parameters
  • zsinit initial water surface elevation

Returns:

true if test passed


function ThackerLakeAtRest< double >

template bool ThackerLakeAtRest< double > (
    Param XParam,
    double zsinit
) 

function ThackerLakeAtRest< float >

template bool ThackerLakeAtRest< float > (
    Param XParam,
    float zsinit
) 

function ValleyBathy

create V shape Valley basin

template<class T>
T ValleyBathy (
    T x,
    T y,
    T slope,
    T center
) 

!

This function creates a simple V shape Valley basin

Parameters:

  • x x coordinate
  • y y coordinate
  • slope slope of the valley sides
  • center x coordinate of the valley center

Returns:

the depth of the basin at point (x,y)


function ZoneOutputTest

Test the zoned output This function test the zoned output for a basic configuration.

template<class T>
bool ZoneOutputTest (
    int nzones,
    T zsinit
) 

!

Parameters:

  • nzones Number of zones to test (1 or 3)
  • zsinit Initial water level

Returns:

true if test passed


function ZoneOutputTest< double >

template bool ZoneOutputTest< double > (
    int nzones,
    double zsinit
) 

function ZoneOutputTest< float >

template bool ZoneOutputTest< float > (
    int nzones,
    float zsinit
) 

function alloc_init2Darray

Allocates and initializes a 2D array This function allocates and fills a 2D array with zero values.

void alloc_init2Darray (
    float ** arr,
    int NX,
    int NY
) 

!

Parameters:

  • arr Pointer to the 2D array
  • NX Number of rows
  • NY Number of columns

function copyBlockinfo2var

Copies block info to an output variable This function copies block info to an output variable This function is somewhat useful when checking bugs in the mesh refinement or coarsening one needs to provide a pointer(z) allocated on the CPU to store the clockinfo This fonction only works on CPU.

template<class T>
void copyBlockinfo2var (
    Param XParam,
    BlockP < T > XBlock,
    int * blkinfo,
    T * z
) 

!

Parameters:

  • XParam Model parameters (only nblk, blkwidth, xo, yo, xmax, ymax and dx are used)
  • XBlock Block parameters (only active is used)
  • blkinfo Block information array (CPU)
  • z Array to fill

function copyBlockinfo2var< double >

template void copyBlockinfo2var< double > (
    Param XParam,
    BlockP < double > XBlock,
    int * blkinfo,
    double * z
) 

function copyBlockinfo2var< float >

template void copyBlockinfo2var< float > (
    Param XParam,
    BlockP < float > XBlock,
    int * blkinfo,
    float * z
) 

function copyID2var

Copies block ID to an output variable This function copies block info to an output variable This function is somewhat useful when checking bugs in the mesh refinement or coarsening one needs to provide a pointer(z) allocated on the CPU to store the clockinfo This fonction only works on CPU.

template<class T>
void copyID2var (
    Param XParam,
    BlockP < T > XBlock,
    T * z
) 

!

Parameters:

  • XParam Model parameters (only nblk, blkwidth, xo, yo, xmax, ymax and dx are used)
  • XBlock Block parameters (only active is used)
  • z Array to fill

function copyID2var< double >

template void copyID2var< double > (
    Param XParam,
    BlockP < double > XBlock,
    double * z
) 

function copyID2var< float >

template void copyID2var< float > (
    Param XParam,
    BlockP < float > XBlock,
    float * z
) 

function diffArray

template<class T>
void diffArray (
    Param XParam,
    BlockP < T > XBlock,
    std::string varname,
    bool checkhalo,
    T * cpu,
    T * gpu,
    T * dummy,
    T * out
) 

function diffSource

Calculate The source term of the equation This function Calculate The source term of the equation. This function is quite useful when checking for Lake-at-Rest states This function requires an outputCPU pointers to save the result of the calculation.

template<class T>
void diffSource (
    Param XParam,
    BlockP < T > XBlock,
    T * Fqux,
    T * Su,
    T * output
) 

!

Parameters:

  • XParam Model parameters (only nblk and blkwidth are used)
  • XBlock Block parameters (only active are used)
  • Fqux Input array
  • Su Input array
  • output Output array (source term)

function diffdh

Calculate The difference between adjacent cells in an array This function Calculates The difference in left and right flux terms. This function is quite useful when checking for Lake-at-Rest states This function requires a preallocated output and a shuffle (right side term) CPU pointers to save the result of teh calculation.

template<class T>
void diffdh (
    Param XParam,
    BlockP < T > XBlock,
    T * input,
    T * output,
    T * shuffle
) 

!

Parameters:

  • XParam Model parameters (only nblk and blkwidth are used)
  • XBlock Block parameters (only active are used)
  • input Input array
  • output Output array (difference)
  • shuffle Output array (right side term)

function fillgauss

Fill an array with a gaussian bump This function fill an array with a gaussian bump.

template<class T>
void fillgauss (
    Param XParam,
    BlockP < T > XBlock,
    T amp,
    T * z
) 

!

borrowed/adapted from Basilisk test (?)

Parameters:

  • XParam Model parameters (only nblk, blkwidth, xo, yo, xmax, ymax and dx are used)
  • XBlock Block parameters (only active, level, xo and yo are used)
  • amp Amplitude of the gaussian bump
  • z Array to fill

function fillgauss< double >

template void fillgauss< double > (
    Param XParam,
    BlockP < double > XBlock,
    double amp,
    double * z
) 

function fillgauss< float >

template void fillgauss< float > (
    Param XParam,
    BlockP < float > XBlock,
    float amp,
    float * z
) 

function fillrandom

Fill an array with random values This function fill an array with random values (0 - 1)

template<class T>
void fillrandom (
    Param XParam,
    BlockP < T > XBlock,
    T * z
) 

!

Parameters:

  • XParam Model parameters (only nblk and blkwidth are used)
  • XBlock Block parameters (only active are used)
  • z Array to fill

function fillrandom< double >

template void fillrandom< double > (
    Param XParam,
    BlockP < double > XBlock,
    double * z
) 

function fillrandom< float >

template void fillrandom< float > (
    Param XParam,
    BlockP < float > XBlock,
    float * z
) 

function init3Darray

Initializes a 3D array This function fill a 3D array with zero values.

void init3Darray (
    float *** arr,
    int rows,
    int cols,
    int depths
) 

!

Parameters:

  • arr Pointer to the 3D array
  • rows Number of rows
  • cols Number of columns
  • depths Number of depths

function reductiontest

Reduction test Test the algorithm for reducing the global time step on the user grid layout.

template<class T>
bool reductiontest (
    Param XParam,
    Model < T > XModel,
    Model < T > XModel_g
) 

!

Parameters:

  • XParam Model parameters
  • XModel CPU model
  • XModel_g GPU model

Returns:

true if test passed


function reductiontest< double >

template bool reductiontest< double > (
    Param XParam,
    Model < double > XModel,
    Model < double > XModel_g
) 

function reductiontest< float >

template bool reductiontest< float > (
    Param XParam,
    Model < float > XModel,
    Model < float > XModel_g
) 

function testButtingerX

Test the Buttinger scheme in X direction This function goes through the Buttinger scheme but instead of the normal output just prints all teh usefull values This function is/was used in the lake-at-rest verification.

template<class T>
void testButtingerX (
    Param XParam,
    int ib,
    int ix,
    int iy,
    Model < T > XModel
) 

!

See also: void testkurganovX(Param XParam, int ib, int ix, int iy, Model<T> XModel)

Parameters:

  • XParam Model parameters
  • ib Block index
  • ix X index in the block
  • iy Y index in the block
  • XModel Model variables

function testboundaries

template<class T>
bool testboundaries (
    Param XParam,
    T maxslope
) 

function testkurganovX

Test the Kurganov scheme in X direction This function goes through the Kurganov scheme but instead of the normal output just prints all teh usefull values This function is/was used in the lake-at-rest verification See also: void testButtingerX(Param XParam, int ib, int ix, int iy, Model<T> XModel)

template<class T>
void testkurganovX (
    Param XParam,
    int ib,
    int ix,
    int iy,
    Model < T > XModel
) 

!

Parameters:

  • XParam Model parameters
  • ib Block index
  • ix X index in the block
  • iy Y index in the block
  • XModel Model variables

function vectoroffsetGPU

A simple kernel to add an offset to a vector This is used to test the pin memory allocation and transfer between CPU and GPU.

template<class T>
__global__ void vectoroffsetGPU (
    int nx,
    T offset,
    T * z
) 

Parameters:

  • nx Number of elements in the vector
  • offset Offset to add
  • z Vector to modify (input and output)

Template parameters:

  • T Data type of the vector (float or double)


The documentation for this class was generated from the following file src/Testing.cu