Heightfield 1.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
HeightFieldSediment Class Reference

A height field with one sediment (sand) layer. More...

#include <heightfieldsediment.h>

Inheritance diagram for HeightFieldSediment:
Array2 Box2 LayerStack LayerFieldErosion

Public Member Functions

 HeightFieldSediment ()
 Create an empty terrain.
 
 HeightFieldSediment (const Box2 &, int, int)
 Create a flat terrain with no sediments. More...
 
 HeightFieldSediment (const ScalarField2 &)
 Create a terrain with no sediments from an elevation field. More...
 
 HeightFieldSediment (const ScalarField2 &, const ScalarField2 &)
 Create a terrain with sediments. More...
 
 ~HeightFieldSediment ()
 Empty.
 
Array2 GetArray () const
 Return the array representing the grid domain.
 
ScalarField2 AlphaBlend () const
 Compute the alpha blending between sand and bedrock.
 
HeightField GetHeightField () const
 Convert the layered model into a simple heightfield.
 
void SmoothRock (int=1)
 Smoothes the bedrock layer. More...
 
HeightFieldGetBedrock ()
 Access to the bedrock scalar field.
 
ScalarField2GetSand ()
 Access to the sand scalar field.
 
double Bedrock (const Vector2 &) const
 Compute the bedrock elevation. More...
 
double Bedrock (int, int) const
 Return the bedrock elevation. More...
 
double Sand (const Vector2 &) const
 Compute the sand thickness. More...
 
double Sand (int, int) const
 Return the sand thickness. More...
 
void Subdivide ()
 Double the resolution of the terrain.
 
void BedrockFlatten (const Vector2 &, const double &, const double &=0.25)
 Flatten the bedrock around the target point. More...
 
void BedrockLevel (const Vector2 &, const double &, const double &)
 Level the bedrock to the target elevation. More...
 
void BedrockUplift (const double &)
 Modify the bedrock using a uniform uplift. More...
 
void BedrockUplift (const ScalarField2 &)
 Uplift. More...
 
void ThermalImpact (const double &)
 Globally transform a thin layer of bedrock into sediments. More...
 
void ThermalImpactSlope (const double &)
 Globally transform a thin layer of bedrock into sediments. More...
 
void Stabilize (const double &, const double &=0.84)
 Stabilizes sediments over the entire terrain. More...
 
bool StabilizeStep (int, int, const double &, ScalarField2 &)
 Perform a stabilization step on the given layered cell. More...
 
int CheckFlowSlope (const QPoint &, FlowStruct &) const
 Compute the flow directions at a given point. More...
 
int CheckFlowDirectionsAngle (const QPoint &, const double &, QPoint *, double *, double *, double *) const
 Compute the flow directions at a given point. More...
 
bool SelectFlowDirection (const QPoint &, QPoint &, double &) const
 Select flow direction. More...
 
void TRUC (const QPoint &q, const double &slope, const double &V_T, double &V_T_S, double &V_E_R, double &V_E_S, double &V_D_S)
 Compute eroded material.
 

Protected Member Functions

void Evaporate (const double &, const double &, double &, double &, double &)
 Evaporate some water from the droplet.
 

Protected Attributes

HeightField bedrock
 Bedrock.
 
ScalarField2 sand
 Sand, i.e., sediments.
 

Detailed Description

A height field with one sediment (sand) layer.

Constructor & Destructor Documentation

◆ HeightFieldSediment() [1/3]

HeightFieldSediment::HeightFieldSediment ( const Box2 box,
int  nx,
int  ny 
)

Create a flat terrain with no sediments.

Parameters
nx,nySubdivision of the terrain.
boxRectangular domain.

◆ HeightFieldSediment() [2/3]

HeightFieldSediment::HeightFieldSediment ( const ScalarField2 b)

Create a terrain with no sediments from an elevation field.

Parameters
bBedrock.

◆ HeightFieldSediment() [3/3]

HeightFieldSediment::HeightFieldSediment ( const ScalarField2 b,
const ScalarField2 s 
)

Create a terrain with sediments.

Parameters
bBedrock.
sSediments.

Member Function Documentation

◆ Bedrock() [1/2]

double HeightFieldSediment::Bedrock ( const Vector2 p) const
inline

Compute the bedrock elevation.

Parameters
pPoint.

◆ Bedrock() [2/2]

double HeightFieldSediment::Bedrock ( int  i,
int  j 
) const
inline

Return the bedrock elevation.

Parameters
i,jInteger coordinates.

◆ BedrockFlatten()

void HeightFieldSediment::BedrockFlatten ( const Vector2 c,
const double &  r,
const double &  s = 0.25 
)

Flatten the bedrock around the target point.

The neighboring elevation should converge to the terrain level at target point.

Parameters
cCenter.
rRadius.
sScaling of the effect.

◆ BedrockLevel()

void HeightFieldSediment::BedrockLevel ( const Vector2 c,
const double &  r,
const double &  z 
)

Level the bedrock to the target elevation.

Parameters
cCenter.
rRadius.
zElevation.

◆ BedrockUplift() [1/2]

void HeightFieldSediment::BedrockUplift ( const double &  u)

Modify the bedrock using a uniform uplift.

Parameters
uConstant ulift.

◆ BedrockUplift() [2/2]

void HeightFieldSediment::BedrockUplift ( const ScalarField2 u)

Uplift.

Parameters
uUplift scalar field.

◆ CheckFlowDirectionsAngle()

int HeightFieldSediment::CheckFlowDirectionsAngle ( const QPoint &  p,
const double &  s,
QPoint *  point,
double *  height,
double *  slope,
double *  nslope 
) const

Compute the flow directions at a given point.

Parameters
pPoint.
sSlope, i.e. tangent of repose angle.
pointArray of neighboring points.
heightArray of height difference
slopeArray of slopes.
nslopeArray of normalized slopes.

◆ CheckFlowSlope()

int HeightFieldSediment::CheckFlowSlope ( const QPoint &  p,
FlowStruct &  flow 
) const

Compute the flow directions at a given point.

Parameters
pPoint.
flowFlow information.

◆ Sand() [1/2]

double HeightFieldSediment::Sand ( const Vector2 p) const
inline

Compute the sand thickness.

Parameters
pPoint.

◆ Sand() [2/2]

double HeightFieldSediment::Sand ( int  i,
int  j 
) const
inline

Return the sand thickness.

Parameters
i,jInteger coordinates.

◆ SelectFlowDirection()

bool HeightFieldSediment::SelectFlowDirection ( const QPoint &  a,
QPoint &  b,
double &  slope 
) const

Select flow direction.

Compute the different flow directions and perform a random selection among candidates.

Parameters
aCell.
bReturned neighboring cell.
slopeReturned slope.

◆ SmoothRock()

void HeightFieldSediment::SmoothRock ( int  n = 1)

Smoothes the bedrock layer.

Parameters
nNumber of iterations.

◆ Stabilize()

void HeightFieldSediment::Stabilize ( const double &  e,
const double &  sar = 0.84 
)

Stabilizes sediments over the entire terrain.

This is a an optimized algorithm with an internal queue to handle only the relevant unstable stacks during the stabilization process.

Parameters
eElevation of sediments transported at every step of the algorithm.
sarSlope corresponding to the critical angle of repose, by default tan(40°) ~ 0.84.

Without optimization, the brute force stabilization algorithm may be implemented as follows:

bool stabilized = false;
int iterations = 0;
ScalarField2 moved(Box2(a, b), nx, ny, 0.0);
ScalarField2 deltaSand(Box2(a, b), nx, ny);
while (!stabilized && (iterations < n))
{
stabilized = true;
deltaSand.Fill(0.0);
for (int i = 0; i < nx; i++)
{
for (int j = 0; j < ny; j++)
{
bool flag = StabilizeStep(i, j, e, deltaSand);
stabilized &= flag;
}
}
sand.Add(deltaSand);
deltaSand.Abs();
moved.Add(deltaSand);
iterations++;
Vector2 b
ScalarField2 sand
Sand, i.e., sediments.
Definition: heightfieldsediment.h:9
bool StabilizeStep(int, int, const double &, ScalarField2 &)
Perform a stabilization step on the given layered cell.
Definition: heightfieldsand.cpp:337
void Add(const Vector2 &, const double &)

◆ StabilizeStep()

bool HeightFieldSediment::StabilizeStep ( int  x,
int  y,
const double &  eee,
ScalarField2 deltaSand 
)

Perform a stabilization step on the given layered cell.

Returns
true if the cell was stable, false otherwise.

◆ ThermalImpact()

void HeightFieldSediment::ThermalImpact ( const double &  s)

Globally transform a thin layer of bedrock into sediments.

Parameters
sThickness (in meters).

◆ ThermalImpactSlope()

void HeightFieldSediment::ThermalImpactSlope ( const double &  s)

Globally transform a thin layer of bedrock into sediments.

Parameters
sThickness (in meters).