//
// The Coastline Evolution Model 2D (CEM2D) - © Copyright 2019 Chloe Leach
//
// The Coastline Evolution Model 2D (CEM2D) is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by.
// the Free Software Foundation, either version 3 of the License.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// The Coastline Evolution Model 2D is a modified version of the Coastline Evolution Model (CEM), originally developed by originally developed by
// Ashton et al. (2001), Ashton and Murray (2006) and Valvo et al. (2006)
//
//
using System.IO;
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;
using System.Net;
using System.Xml;
using System.Text.RegularExpressions;
using System.Linq;
using System.Drawing.Drawing2D;
using System.Collections.Generic;
namespace CEM1
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Drawing.Bitmap m_objDrawingSurface;
//JMW
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern long BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwROP);
private System.ComponentModel.IContainer components;
//Jorge variables
public static double sedOut = 0; //amount of sediment at outlet, plotted
public static double waterOut = 0; //amount of water at outlet, plotted
public static int plotType = 0;
public static double magnifyValue = 0;
public static int updateClick = 0;
private double[] zoomFactor = { .25, .33, .50, .66, .80, 1, 1.25, 1.5, 2.0, 2.5, 3.0 };
private double[] contrastFactor = { 1, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8, 3 };
private double contrastMultiplier = 0;
public int imageCount = 0;
public int imageCount2 = 1;
public string kml = "";
public string KML_FILE_NAME = "animation\\animation.kml";
int save_time2, save_interval2 = 0;
public string startDate, kmlTime;
public DateTime googleTime;
public string[] DateArray;
public string[] DateArray2;
// toms global variables
const Single g = 9.81F;
const Single kappa = 0.4F;
double time_1=1;
double save_time=0;
int input_type_flag=0; // 0 is water input from points, 1 is input from hydrograph or rainfall file.
double saveinterval=1000;
int counter=0;
Timer gameClock;
int xmax, ymax;
double xll, yll;
const int ACTIVE_FACTOR=1;
const int TRUE = 1;
const int FALSE = 0;
double DX=5;
double root=7.07;
double fiveroot=10.04;
double time_factor;
double baseflow=0.00000005; //end of hyd model variables usually 0.0000005 changed 2/11/05
public static double cycle=0;
double init_cycle=0;
double output_file_save_interval=60;
int graphics_scale = 5; // value that controls the number of bmp pixels per model pixel for the output images.
// Gez
double tx = 60;
// MJ global vars
int[] deltaX = new int[9] {0,0,1,1,1,0,-1,-1,-1};
int[] deltaY = new int[9] {0,-1,-1,0,1,1,1,0,-1};
double hue = 360.0; // Ranges between 0 and 360 degrees
double sat = 0.90; // Ranges between 0 and 1.0 (where 1 is 100%)
double val = 1.0; // Ranges between 0 and 1.0 (where 1 is 100%)
double red = 0.0;
double green = 0.0;
double blue = 0.0;
string[] inputheader; //Read from ASCII DEM
string basetext = "Modified Coastline Evolution Model (CEM)";
private Graphics mygraphics;
// CM CEM Variables
const double pi = 3.141592654;
double radtodeg = 180 / pi; // Transform rads to degrees
// Time Check
TimeSpan startTime = DateTime.Now.TimeOfDay;
TimeSpan endTime;
TimeSpan speed;
// Setup
int TimeStepValue = 1; // days - reflects rate of sediment transport per time step
double StopAfter; // Stop after what number of time steps
int seed = 1; // random seed: control value = 1 completely random = -999
char StartFromFile; // start from saved file?
char InitialiseFile = 'n'; // use a file to initialise run? Over rides setup data
string[] readcontrolname = new string[] { "INPUT_FILES/CEM_control.dat" };
double[] ControlFileIn = new double[20]; // Initialisation data read from file
int NoPauseRun = 1; // Disbale PauseRun subroutine
string ConfigName = null; // Name of default ConfigFile (blank!)
int Resuldata_freq = 3650;
// Dimensions - periodic boundary/display
int xDisplayStart;
int xDisplayEnd;
int pbEnd;
static int CellWidth = 100; // size of cells (meters)
static int MaxBeachLength; // maximum length of arrays that contain beach data at each time step
//DEM From File
string fileContent_DEM; // Used to read entire DEM file
string[] fileSplit;
double coastrotation = 0; // Angle (deg) used to align coastline with real wave climate
string DEMFilePath;// = Directory.GetCurrentDirectory() + "/INPUT_FILES/CEM_PertShort.dat"; // File path for loaded DEM
int InitBeach = 25; // cell where intial conditions changes from beach to ocean
int InitRock = 5; // cell where initial conditions change from beach to rock LMV
int InitCType; // 0: normal (columns/blocks), 1: wiggly, 2: one block
int InitialDepth = 10; // theoretical depth in meters of continental shelf at x = InitBeach
int InitialPert; // Start with a bump? if =1-->square pert, if =2-->pointy pert
int DiffusiveHump = 0; // Shoreline is sinusoidal LMV
int InitialSmooth = 0; // Smooth starting conditions (1=smooth 0=rough))
int InitialSmoothRock = 1; // Smooth rock interface starting conditions LMV (1=smooth 0=rough)
// Waves
int WaveIn; // Input Wave Distribution file: no = 0, binned file = 1, angle/period/height file = 2, manualentry = 3
double WaveAngle; // wave angle for current time step
double OffShoreWvHt = 1.7; // meters
double Period = 8.0; // seconds
double Asym; // fractional portion of waves coming from positive (left) direction
double Highness; // .5 = even dist, > .5 high angle domination.
double Duration = 1; // Number of time steps calculations loop at same wave angle
double waveheightchange = 1; // Factor applied to the input wave height; 1 = no change, 0.5 = half wave height, and 2 = double wave height
double waveperiodchange = 1; // Factor applied to the input wave period; 1 = no change, 0.5 = half wave period, and 2 = double wave period
string readwavename;
string realWave_Content; // Used to read entire real wave file
string[] realWave_Split;
int Wavecount = 0; // Used to count cycle through wave data from file
int NumWaveBins; // For Input Wave - number of bins
double[] WaveMax = new double[36]; // Max Angle for specific bin
double[] WaveProb = new double[36]; // Probability of Certain Bin
double WaveAngleIn;
double WaveHeightIn;
double WavePeriodIn;
// Tides
int DoTides; // Run with tides = 1, run without tides = 0
double WaterLevel; // What height is the tide?
double HighWaterHeight; // Level of HighTide
double[] WLArray;
int WLCount = -1;
// SLR
int DoSLR; // Run with SLR = 1, run without SLR = 0
double SLR; // Amount of SLR
int SLRrate; // Period over which SLR rises
double[] SLRArray; // Stores incremental SLR over x years
int SLRCount = -1;
// Weathering/Erosion
int MaxFillCell = 1; // Value representing that a cell if 100% full of material - Used as an indicator to see if a cell is 100% Full
const int NumberChunk = 0; // Number of chunks of rock in alongshore direction with different weathering rates LMV
int ChunkLength; // Alongshore length of a chunk of fast or slow weathering rock LMV (used to be xmax/NumberChunk)
double NoWeathering; // weathering of rock only occurs below this amt of sed cover (vert equiv in meters) LMV */
double SlowWeatherCoeff; // Weathering rate of slow rock e.g. 0.5 = slow weathering, 1/2 as fast LMV
double FastWeatherCoeff; // Weathering rate of fast rock e.g. 2 = fast weathering, 2 times faster than normal LMV
double PercentFineFast; // Percent of fast weathering rock lost because it is too fine to stay in nearshore LMV
double PercentFineSlow; // Percent of slow weathering rock lost because it is too fine to stay in nearshore LMV
double ErosionRatePerYear; // Amount of erosion to TotalBeachCells in m/year LMV
double CurrentPercentFine = 0;
double CliffHeight = 0; // Average cliff height in (m)
// Shoreface
double ShelfSlope = 0.1; // slope of continental shelf
double ShorefaceSlope = 0.01; // for now, linear slope of shoreface
int DepthShoreface = 10; // minimum depth of shoreface due to wave action (meters)
int MaxDist = 50;
// Overwash Parameters
int OWType = 0; // Overwash - 0 = use depth array, 1 = use geometric rule
double CritBWidth = 350.0; // Overwash - width barrier maintains due to overwash (m) important scaling parameter!
int InitBWidth = 4; // Overwash - initial minimum width of barrier (Cells)
double OWMinDepth = 0.01; // Overwash - littlest overwash of all
int OWflag = 0; // A debugging flag for overwash routines
double MaxOver = 0.01; // Maximum overwash step size (enforced at back barrier)
double OverwashLimit = 60; // Don't do over wash if the angle is > 60 degrees
double[,] CellDepth; // Depth array
// Beach
int TimeToSweepFullBeach = 50; // Spacing of full beach sweep for each rock cell i=0:TotalBeachCells LMV
int LookDist = 10; // For short rock to beach sweep, +- number of beach cells to look at LMV
double BigDistanceToBeach = 1000.0 * CellWidth; // Used to find minimum distance to beach in rock to beach sweep LMV
double MassInitial; // For conservation of mass calcs
double MassCurrent;
// Find Beach/Rock - Draw the 'Coast'
int FindStart; // Used to tell FindBeach at what Y value to start looking
int FindRockStart; // Used to tell FindRock at what Y value to start looking LMV
int NextX; // Global variables used to iterate FindNextCell in global array
int NextY; // Would've used pointer but wouldn't work
int BehindX;
int BehindY;
int BehindRockX;
int BehindRockY;
int NextRockX; // Global variables used to iterate FindNextRockCell in global array LMV
int NextRockY;
int TotalBeachCells; // Number of cells describing beach at particular iteration
int TotalRockCells; // Number of cells describing rock at an iteration LMV
char FellOffArray; // Flag used to determine if accidentally went off array
char FellOffRockArray; // Flag used to determine if accidentally went off rock array LMV
int FindCellError = 5; // if we run off of array, how far over do we try again?
//Shadow
double ShadowStepDistance = 0.2; // step size for shadow cell checking
int ShadowYMax; // used to determine maximum extent of beach cells
// Sources and Sinks
int HaveSinks; // include sediment sinks in model run? 0 no, 1 yes
int NumSinks;
int ColumnSinks; // if this is turned on, X vector is disregarded and a sink is considered to span a whole column
int[] SinkY; // a sink is a cell that is routinely emptied (if it is on the beach)
int[] SinkX;
double Sinkiness; // fractional value determines chance that sediment in the sink is deleted
int NumSources;
int ColumnSources; // if this is turned on, X vector is disregarded and a sink is considered to span a whole column
int[] SourceY; // a source cell when on beach
int[] SourceX;
//Age Cells
int AgeMax = 1000000; // Maximum 'age' of cells - loops back to zero
int AgeUpdate = 10; // Time space for updating age of non-beach cells
// Save
int SaveFrequency; // Counter interval to save image
int SaveDEM = 1;
int SaveSpacing; // space between saved files
string savefilename;
char Metadata = 'y'; // Create a metadata file?
string[] metasavename = new string[] { "OUTPUT_FILES/Metadata.out" }; // array size was originally 24?
char Wavedata = 'y'; // Create a wavedata file?
string wavesavename;
int SaveImage = 1; // Save as PNG image?
int StartSavingAt = 0; // Number to start saving at
int SaveFile = 2; // 1 = line output, 2 = array output
int SaveAge = 0; // Save/update age of cells?
int SaveLine = 0; // Save line instead of whole array?
int SandOutCol = 150; // save the amount of sand in the cells of this column at each time step
//double SandAmount = 0;
string[] sandamountsave = new string[] { "SandAmount.out" };
double TotalVolumePerIt; // Counts how much sediment is moved across the entire area on each iteration
//string MovedSedVolPath = "OUTPUT_FILES/MovedSedVol.dat";
// Overall Shoreface Configuration Arrays
int[,] AllBeach; // Flag indicating of cell is entirely beach - 1 = yes, 0 = no
int[,] AllRock; // Flag indicating if cell is entirely rock LMV
double[,] PercentFullSand; // Fractional amount of cell full of sediment LMV
double[,] PercentFullRock; // Fractional amount of a cell full of rock LMV
char[,] TypeOfRock; // Array to control weathering rates of rock along the beach LMV
int[,] Age; // Age since cell was deposited
bool[,] AboveTideOLD; // Flag indicating if a cell is above the tide mark - OLD WAY!! Not
int[,] AboveWater; // Is cell above water mark? 1 = yes, 0 = no (WaterHeight)
int[,] ShorelineCell; // 1 = yes, 0 = no
int[,] Linear_Shoreline;
// Computational Arrays (determined for each time step)
int[] X; // X Position of ith beach element
int[] Y; // Y Position of ith beach element
int[] initialX;
int[] initialY;
int[] XBehind; // Cell that is "behind" X[i] LMV
int[] YBehind; // Cell that is "behind" Y[i] LMV
int[] XRock; // X Position of ith rock element LMV
int[] YRock; // Y Position of ith rock element LMV
int[] XRockBehind; // Cell that is "behind" XRock[i] LMV
int[] YRockBehind; // Cell that is "behind" YRock[i] LMV
char[] InShadow; // Is ith beach element in shadow?
double[,] InShadow_domain;
double[] ShorelineAngle; // Angle between cell and right (z+1) neighbor
double[] SurroundingAngle; // Angle between left and right neighbors
char[] UpWind; // Upwind or downwind condition used to calculate sediment transport
double[] VolumeIn; // Sediment volume into ith beach element
double[] VolumeOut; // Sediment volume out of ith beach element
double[] VolumeAcrossBorder; // Sediment volume across border of ith beach element in m^3/day LMV
double[] ActualVolumeAcross; // Sediment volume that actually gets passed across border LMV - amount sed is limited by volumes across border upstream and downstream
char[] DirectionAcrossBorder; // Flag to indicate if transport across border is L or R LMV
char[] FlowThroughCell; // Is flow through ith cell Left, Right, Convergent, or Divergent LMV
double[] DistanceToBeach; // Distance in meters from rock to beach LMV
double[] MinDistanceToBeach; // From a rock cell j, min distance (in meters) to closest beach LMV
int[] ClosestBeach = new int[MaxBeachLength]; // i position of closest rock to beach LMV
double[] AmountWeathered; // Amount of rock weathered from rock cell j LMV
// Depth
double Depth; // Depth of current cell
double Distance; // distance from shore to intercept of equilib. profile and overall slope (m)
double Yintercept; // Y position of intercept of equilib. profile and overall slope
double DepthEffective; // depth at x intercept, Brad: where slope becomes < equilib slope, so sand stays piled against shoreface
// CM - Adding elevation volumes
int[,] LowestX; // X position of lowest neighbour
int[,] LowestY; // Y position of lowest neighbour
double CriticalAngle = 34; // Specified Angle of Repose
double[,] SedimentChange; // Used to keep track of sed. vol. added and removed from each cell during diffusion
double[,] VolumeChange;
double[,] DepthEffectiveArray;
double heighestElev = 0;
double WDThreshold = 0.005; // Wet/Dry Threshold - Amount cell needs to be above/below water level for it to be entirely above/below based on local SFS
double TotalSediment = 0; // Total amount of sediment in the DEM at the start of the simulation
double[] Angle_1;
// CM - Graphics
double zElevMin;
double zElevMax;
double zDepthvMin;
double zDepthMax;
// CM - 2D structure
double[,] Elevation; // Elevation of beach
double[,] WaterDepth0; // Water depth from DEM (ref: 0m)
double[,] DepthShelf; // Depth from '0' to Shelf
double[,] DomainDepthCS; // Depth to domain bottom from continental shelf
double maxDomainDepth; // Used as a reference point for elevation, cell depth etc (contant flat)
double[,] DepthShelfMaterial; // Depth of material to shelf from 0 level (will sometimes be same as depthShelf)
double[,] TElevationCS; // Total elevation of material from continental shelf (used to work out volume!)
double[,] TElevationDomain; // Total elevation of material from bottom of the domain (used to work out above/below water)
double[,] Volume; // Volume of material in each cell
double[,] OriginalVol;
double[,] PreviousVolume;
double TotalVolumeStart = 0;
double TotalVolAboveStart = 0;
double TotalVolumeEnd = 0;
double TotalVolAboveEnd = 0;
int[] XSt;
int[] YSt;
double WetDryThreshold; // Hight of cell above/below water to consider it a wet/dry cell
int[] direction; // 1 = Top 2 = Top right 3 = Right 4 = Bottom Right 5 = Bottom 6 = Bottom left 7 = Left 8 = Top Left
int[] numCells; // How many cells from the coastline do we extend out for the shoreface slope?
double[] localSFS;
// Recording Output Data
double Vol_Wet = 0;
double Cells_Wet = 0;
double Vol_Dry = 0;
double Cells_Dry = 0;
double Start_Vol_Wet = 0;
double Start_Cells_Wet = 0;
double Start_Vol_Dry = 0;
double Start_Cells_Dry = 0;
// Batch
static int Restart_count; // Counter for restart loop
static int autorestart = 1; // 1 = yes autorestart, 0 = no autorestart
static int maxRuns = 1;
// De-bugging Parameters
int debug0 = 0; // misc. printf's--don't leave them in
int debug1 = 0; // Find Next Beach Cell
int debug1a = 0; // Find Next Rock Cell LMV
int debug1b = 0; // More find next cell LMV
int debug1c = 0; // More find next rock cell LMV
int debug2 = 0; // Shadow Routine
int debug2a = 0; // In-Depth Shadow Results
int debug2b = 0; // More shadow results
int debug3 = 0; // Determine Angles
int debug4 = 0; // Upwind/Downwind
int debug5 = 0; // Sediment Transport Decisions
int debug6 = 0; // Sediment Trans Calculations
int debug6a = 0; // Volume In/Out/AcrossBorder LMV
int debug7 = 0; // Transport Sweep (move sediment)
int debug7a = 0; // Slope Calcs
int debug8 = 0; // Full/Empty
int debug80 = 0; // Temp Full
int debug8a = 0; // More Full/Empty LMV
int debug9 = 0; // FixBeach
int debug9a = 0; // More FixBeach LMV
int debug10 = 0; // Distance to Beach LMV
int debug11 = 0; // Min Distance to Beach & Closest Beach LMV
int debug12 = 0; // Weathering Rate LMV
int debug12a = 0; // Percent Fines lost LMV
int debug13 = 0; // Sed Flow LMV
int debug14 = 0; // Actual Volume Across Border & PFS LMV
int debug15 = 0; // Erosion Rate per Year LMV
int debug16 = 0; // Total Percent Full LMV
int debug17 = 0; // graphics stuff
int debug18 = 0; // reading wave data AB
int debugNearest = 0; // graphs a pixel at nearest beach cell to a given rock cell (for weathering)
string DebugFilePath = "OUTPUT_FILES/DebugFile.out"; // Debugs above write to this file
string TestFilePath = "OUTPUT_FILES/TestFile.out"; // Used to print values for quick checks/debugging
int FlasgLandslide = 0;
double lost = 0;
int hit = 0;
int FlowZeroCount = 0;
// END CM CEM Variables //
//Buttons and Menus
private System.Windows.Forms.Button loadDataButton;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItemFile;
private System.Windows.Forms.MenuItem menuItemFileOpen;
private System.Windows.Forms.MenuItem menuItemFileSave;
private System.Windows.Forms.MenuItem menuItemFileSaveAs;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.StatusBarPanel IterationStatusPanel;
private System.Windows.Forms.StatusBarPanel TimeStatusPanel;
private System.Windows.Forms.StatusBarPanel QwStatusPanel;
private System.Windows.Forms.StatusBarPanel QsStatusPanel;
private System.Windows.Forms.StatusBarPanel InfoStatusPanel;
private System.Windows.Forms.StatusBarPanel waveAnglePanel;
private System.Windows.Forms.Button startButton;
private System.Windows.Forms.Button quitSaveButton;
private System.Windows.Forms.Button updateGraphicsButton;
private System.Windows.Forms.Panel UpdateGraphPanel;
private Smallwisdom.Windows.Forms.ZoomPanImageBox zoomPanImageBox1;
private TrackBar trackBar1;
private GroupBox Graphic_ContrastSlider;
private Label ContrastLab;
private GroupBox ZoomSlider;
private Label ZoomLab;
private TrackBar trackBar2;
private CheckBox ViewTabsCheck;
private Button pauseButton;
private Button resumeButton;
private OpenFileDialog openFileDialog1;
private TabPage DescriptionTab;
private TabPage WaveTab;
private TextBox WPLoadTB;
private TextBox WALoadTB;
private TextBox WHLoadTB;
private TextBox WPeriodTB;
private TextBox WAngleTB;
private TextBox WHeightTB;
private TextBox WaveFileTB;
private Label WPLoadLab;
private Label WALoadLab;
private Label WHLoadLab;
private Label ManWavLabel;
private CheckBox ManWavTick;
private Label WavSourceTitle;
private Label ManWavTitle;
private Label LoadWaveTitle;
private Label BinnedLabel;
private CheckBox BinnedTick;
private Label WaveTickLabel;
private CheckBox WaveFileTick;
private Label WPeriodLabel;
private Label WAngleLabel;
private Label WHeightLabel;
private Button WaveBrowseButton;
private Label WaveFileLabel;
private Microsoft.VisualBasic.PowerPacks.ShapeContainer shapeContainer2;
private Microsoft.VisualBasic.PowerPacks.LineShape lineShape2;
private TabPage DEMTab;
private Label DEMDimTitle;
private Label DEMSourceTitle;
private TextBox RowsTB;
private Label RowLabel;
private Label ColLabel;
private TextBox ColumnTB;
private Label BlockLabel;
private CheckBox BlockTick;
private Label WigglyLabel;
private CheckBox WigglyTick;
private Label NormLabel;
private CheckBox NormTick;
private Label CompDEMLabel;
private CheckBox CompDEMTick;
private Label DEMLabel;
private CheckBox DEMTick;
private Button DEMBrowseButton;
private TextBox DEMTextBox;
private Microsoft.VisualBasic.PowerPacks.ShapeContainer shapeContainer1;
private Microsoft.VisualBasic.PowerPacks.LineShape lineShape1;
private TabControl MainWindowTabs;
private TabPage TideTab;
private TextBox LowTideTB;
private Label LowTideLab;
private TextBox HighTideTB;
private Label HighTideLab;
private TabPage ErosionTab;
private TextBox ErosRateTB;
private Label ErosRateLab;
private TextBox SlowWeatherTB;
private Label SlowWeatherLab;
private TextBox RockWeatherTB;
private Label RockWeatherLab;
private TextBox PercentSlowTB;
private Label PercentSlowLab;
private TextBox PercentFastTB;
private Label PercentFastLab;
private TextBox FastWeatherTB;
private Label FastWeatherLab;
private TabPage SourceSinkTab;
private Label WeatheringTitle;
private Label ErosionTitle;
private Microsoft.VisualBasic.PowerPacks.ShapeContainer shapeContainer3;
private Microsoft.VisualBasic.PowerPacks.LineShape lineShape4;
private Label SinksTab;
private Label SourcesTab;
private TextBox NumSourceTB;
private Label NumSourceLab;
private Microsoft.VisualBasic.PowerPacks.ShapeContainer shapeContainer4;
private Microsoft.VisualBasic.PowerPacks.LineShape lineShape5;
private TextBox NumSinkTB;
private Label NumSinkLab;
private CheckBox SinkTick;
private Label SinkTickLab;
private CheckBox SourceTick;
private Label SourceTickLab;
private CheckBox ColSinkTick;
private Label ColSinkLab;
private TextBox YSinkTB;
private Label YSinkLab;
private TextBox XSinkTB;
private Label XSinkLab;
private TextBox YSourceTB;
private Label YSourceLab;
private TextBox XSourceTB;
private Label XSourceLab;
private CheckBox ColSourceTick;
private Label ColSourceLab;
private TextBox SinkinessTB;
private Label SinkinessLab;
private ToolTip CoordTT;
private Label DoTidesLabel;
private CheckBox DoTidesTick;
private Button SeeTabsButton;
private TabPage Outputs;
private TextBox DescripTB;
private MenuItem menuItemGraphics;
private MenuItem menuItemGraphicsRock;
private MenuItem menuItemGraphicsSand;
private MenuItem menuItemGraphicsXY;
private MenuItem menuItemGraphicInitialXY;
private TextBox SaveFreqTB;
private Label SaveFreqLab;
private TextBox OutputNameTB;
private Label OutputNameLab;
private Label label1;
private Label orText;
private Label InitPertLab;
private CheckBox InitPertTick;
private Label PertLab;
private CheckBox PertTick;
private TextBox RunLengthTB;
private Label RunLengthLab;
private MenuItem menuItemGraphicDepth;
private MenuItem menuItemGraphicVolume;
private Label SLRTitle;
private Label TidesTitle;
private Microsoft.VisualBasic.PowerPacks.ShapeContainer shapeContainer5;
private Microsoft.VisualBasic.PowerPacks.LineShape lineShape6;
private TextBox SLR_TB;
private Label SLRLab;
private Label DoSLRLab;
private CheckBox DoSLRTick;
private TextBox RateSLR_TB;
private Label RateSLRLab;
private Label UALab;
private CheckBox UA_WaveTick;
private MenuItem menuItemShadow;
private TextBox AsymTB;
private TextBox HighTB;
private Label AsymLab;
private Label HighLab;
private Label label2;
private Microsoft.VisualBasic.PowerPacks.LineShape lineShape3;
private Label label3;
private Label StepSLR_Lab;
private CheckBox StepSLR_Tick;
private Button SandOutputButton;
// The main entry point for the application.
[STAThread]
// Start the progrm
static void Main()
{
if (autorestart == 1)
{
string dir_name = Environment.CurrentDirectory;
string[] split = dir_name.Split(new[] { "_Split" }, StringSplitOptions.None);
//string[] split_2 = split[1].Split(new[] { '\\' }, StringSplitOptions.None);
Restart_count = Convert.ToInt32(split[1]);
//string Restart_Count_FILE = "INPUT_FILES/Restart_Count_FILE.txt";
//StreamReader reader = new StreamReader(Restart_Count_FILE);
//Restart_count = Convert.ToInt32(reader.ReadToEnd());
//reader.Close();
//StreamWriter writer = new StreamWriter(Restart_Count_FILE);
//writer.Write(Restart_count + 1);
//writer.Close();
Directory.CreateDirectory("OUTPUT_FILES/Run_" + Restart_count);
Directory.CreateDirectory("OUTPUT_FILES/Run_" + Restart_count + "/Simulation");
}
Application.Run(new Form1());
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, System.EventArgs e)
{
zoomPanImageBox1.Height = this.Height - 225;
zoomPanImageBox1.Width = this.Width - 20;
HttpWebRequest req;
HttpWebResponse res;
try
{
req = (HttpWebRequest)WebRequest.Create("http://www.coulthard.org.uk/");
res = (HttpWebResponse)req.GetResponse();
}
catch
{
/// do nothing.
}
this.Text = basetext;
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
// Form Show/Close
private void Form1_Shown(object sender, EventArgs e)
{
// Batch
if (autorestart == 1)
{
if (Restart_count > 1)
{
loadDataButton.PerformClick();
}
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
// Batch
if (autorestart == 1)
{
e.Cancel = false;
}
else
{
pauseButton_Click(pauseButton, EventArgs.Empty);
endTime = DateTime.Now.TimeOfDay;
speed = (endTime - startTime);
DialogResult Result = MessageBox.Show(("Program at " + (counter - 1) + " days \nDo you want to exit? \n\nSpeed: " + speed.Hours + ":" + speed.Minutes + ":" + speed.Seconds + "(hh:mm:ss)"), " ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
if (Result == DialogResult.Yes)
{
StreamWriter EndVol = new StreamWriter("OUTPUT_FILES/MorphChange/EndVol" + WaveFileTB.Text + ".out");
EndVol.Write("ncols " + ColumnTB.Text + Environment.NewLine + "nrows " + RowsTB.Text + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
for (int yyyy = ymax - 1; yyyy >= 0; yyyy--)
{
for (int xxxx = 0; xxxx < pbEnd; xxxx++)
{
EndVol.Write(Volume[xxxx, yyyy] + " ");
TotalVolumeEnd += Volume[xxxx, yyyy];
if (AboveWater[xxxx, yyyy] == 1)
{
TotalVolAboveEnd += Volume[xxxx, yyyy];
}
}
EndVol.Write(Environment.NewLine);
}
EndVol.Write(Environment.NewLine + TotalVolumeEnd + ", " + TotalVolAboveEnd);
EndVol.Close();
StreamWriter XY_End = new StreamWriter("OUTPUT_FILES/MorphChange/XY_End_" + WaveFileTB.Text + ".out");
for (int Loop = 0; Loop < X.Length; Loop++)
{
XY_End.Write(X[Loop] + ", " + Y[Loop] + Environment.NewLine);
}
XY_End.Close();
e.Cancel = false;
}
else
{
resumeButton_Click(resumeButton, EventArgs.Empty);
}
}
}
// Set-up the GUI
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.loadDataButton = new System.Windows.Forms.Button();
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
this.menuItemFile = new System.Windows.Forms.MenuItem();
this.menuItemFileOpen = new System.Windows.Forms.MenuItem();
this.menuItemFileSaveAs = new System.Windows.Forms.MenuItem();
this.menuItemFileSave = new System.Windows.Forms.MenuItem();
this.menuItemGraphics = new System.Windows.Forms.MenuItem();
this.menuItemGraphicsRock = new System.Windows.Forms.MenuItem();
this.menuItemGraphicsSand = new System.Windows.Forms.MenuItem();
this.menuItemGraphicsXY = new System.Windows.Forms.MenuItem();
this.menuItemGraphicInitialXY = new System.Windows.Forms.MenuItem();
this.menuItemGraphicDepth = new System.Windows.Forms.MenuItem();
this.menuItemGraphicVolume = new System.Windows.Forms.MenuItem();
this.menuItemShadow = new System.Windows.Forms.MenuItem();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.InfoStatusPanel = new System.Windows.Forms.StatusBarPanel();
this.IterationStatusPanel = new System.Windows.Forms.StatusBarPanel();
this.TimeStatusPanel = new System.Windows.Forms.StatusBarPanel();
this.QwStatusPanel = new System.Windows.Forms.StatusBarPanel();
this.QsStatusPanel = new System.Windows.Forms.StatusBarPanel();
this.waveAnglePanel = new System.Windows.Forms.StatusBarPanel();
this.startButton = new System.Windows.Forms.Button();
this.quitSaveButton = new System.Windows.Forms.Button();
this.updateGraphicsButton = new System.Windows.Forms.Button();
this.UpdateGraphPanel = new System.Windows.Forms.Panel();
this.SandOutputButton = new System.Windows.Forms.Button();
this.ViewTabsCheck = new System.Windows.Forms.CheckBox();
this.trackBar1 = new System.Windows.Forms.TrackBar();
this.Graphic_ContrastSlider = new System.Windows.Forms.GroupBox();
this.ContrastLab = new System.Windows.Forms.Label();
this.ZoomSlider = new System.Windows.Forms.GroupBox();
this.ZoomLab = new System.Windows.Forms.Label();
this.trackBar2 = new System.Windows.Forms.TrackBar();
this.pauseButton = new System.Windows.Forms.Button();
this.resumeButton = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.DescriptionTab = new System.Windows.Forms.TabPage();
this.DescripTB = new System.Windows.Forms.TextBox();
this.WaveTab = new System.Windows.Forms.TabPage();
this.AsymTB = new System.Windows.Forms.TextBox();
this.HighTB = new System.Windows.Forms.TextBox();
this.AsymLab = new System.Windows.Forms.Label();
this.HighLab = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.UALab = new System.Windows.Forms.Label();
this.UA_WaveTick = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label();
this.WaveBrowseButton = new System.Windows.Forms.Button();
this.WaveFileTB = new System.Windows.Forms.TextBox();
this.WPLoadTB = new System.Windows.Forms.TextBox();
this.WALoadTB = new System.Windows.Forms.TextBox();
this.WHLoadTB = new System.Windows.Forms.TextBox();
this.WPeriodTB = new System.Windows.Forms.TextBox();
this.WAngleTB = new System.Windows.Forms.TextBox();
this.WHeightTB = new System.Windows.Forms.TextBox();
this.WPLoadLab = new System.Windows.Forms.Label();
this.WALoadLab = new System.Windows.Forms.Label();
this.WHLoadLab = new System.Windows.Forms.Label();
this.ManWavLabel = new System.Windows.Forms.Label();
this.ManWavTick = new System.Windows.Forms.CheckBox();
this.WavSourceTitle = new System.Windows.Forms.Label();
this.ManWavTitle = new System.Windows.Forms.Label();
this.LoadWaveTitle = new System.Windows.Forms.Label();
this.BinnedLabel = new System.Windows.Forms.Label();
this.BinnedTick = new System.Windows.Forms.CheckBox();
this.WaveTickLabel = new System.Windows.Forms.Label();
this.WaveFileTick = new System.Windows.Forms.CheckBox();
this.WPeriodLabel = new System.Windows.Forms.Label();
this.WAngleLabel = new System.Windows.Forms.Label();
this.WHeightLabel = new System.Windows.Forms.Label();
this.WaveFileLabel = new System.Windows.Forms.Label();
this.shapeContainer2 = new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
this.lineShape3 = new Microsoft.VisualBasic.PowerPacks.LineShape();
this.lineShape2 = new Microsoft.VisualBasic.PowerPacks.LineShape();
this.DEMTab = new System.Windows.Forms.TabPage();
this.label3 = new System.Windows.Forms.Label();
this.InitPertLab = new System.Windows.Forms.Label();
this.InitPertTick = new System.Windows.Forms.CheckBox();
this.PertLab = new System.Windows.Forms.Label();
this.PertTick = new System.Windows.Forms.CheckBox();
this.orText = new System.Windows.Forms.Label();
this.DEMDimTitle = new System.Windows.Forms.Label();
this.DEMSourceTitle = new System.Windows.Forms.Label();
this.RowsTB = new System.Windows.Forms.TextBox();
this.RowLabel = new System.Windows.Forms.Label();
this.ColLabel = new System.Windows.Forms.Label();
this.ColumnTB = new System.Windows.Forms.TextBox();
this.BlockLabel = new System.Windows.Forms.Label();
this.BlockTick = new System.Windows.Forms.CheckBox();
this.WigglyLabel = new System.Windows.Forms.Label();
this.WigglyTick = new System.Windows.Forms.CheckBox();
this.NormLabel = new System.Windows.Forms.Label();
this.NormTick = new System.Windows.Forms.CheckBox();
this.CompDEMLabel = new System.Windows.Forms.Label();
this.CompDEMTick = new System.Windows.Forms.CheckBox();
this.DEMLabel = new System.Windows.Forms.Label();
this.DEMTick = new System.Windows.Forms.CheckBox();
this.DEMBrowseButton = new System.Windows.Forms.Button();
this.DEMTextBox = new System.Windows.Forms.TextBox();
this.shapeContainer1 = new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
this.lineShape1 = new Microsoft.VisualBasic.PowerPacks.LineShape();
this.MainWindowTabs = new System.Windows.Forms.TabControl();
this.TideTab = new System.Windows.Forms.TabPage();
this.StepSLR_Lab = new System.Windows.Forms.Label();
this.StepSLR_Tick = new System.Windows.Forms.CheckBox();
this.DoSLRLab = new System.Windows.Forms.Label();
this.DoSLRTick = new System.Windows.Forms.CheckBox();
this.RateSLR_TB = new System.Windows.Forms.TextBox();
this.RateSLRLab = new System.Windows.Forms.Label();
this.SLR_TB = new System.Windows.Forms.TextBox();
this.SLRLab = new System.Windows.Forms.Label();
this.SLRTitle = new System.Windows.Forms.Label();
this.TidesTitle = new System.Windows.Forms.Label();
this.DoTidesLabel = new System.Windows.Forms.Label();
this.DoTidesTick = new System.Windows.Forms.CheckBox();
this.HighTideTB = new System.Windows.Forms.TextBox();
this.HighTideLab = new System.Windows.Forms.Label();
this.LowTideTB = new System.Windows.Forms.TextBox();
this.LowTideLab = new System.Windows.Forms.Label();
this.shapeContainer5 = new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
this.lineShape6 = new Microsoft.VisualBasic.PowerPacks.LineShape();
this.ErosionTab = new System.Windows.Forms.TabPage();
this.WeatheringTitle = new System.Windows.Forms.Label();
this.ErosionTitle = new System.Windows.Forms.Label();
this.RockWeatherTB = new System.Windows.Forms.TextBox();
this.PercentSlowTB = new System.Windows.Forms.TextBox();
this.PercentSlowLab = new System.Windows.Forms.Label();
this.PercentFastTB = new System.Windows.Forms.TextBox();
this.PercentFastLab = new System.Windows.Forms.Label();
this.FastWeatherTB = new System.Windows.Forms.TextBox();
this.FastWeatherLab = new System.Windows.Forms.Label();
this.SlowWeatherTB = new System.Windows.Forms.TextBox();
this.SlowWeatherLab = new System.Windows.Forms.Label();
this.ErosRateTB = new System.Windows.Forms.TextBox();
this.ErosRateLab = new System.Windows.Forms.Label();
this.shapeContainer3 = new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
this.lineShape4 = new Microsoft.VisualBasic.PowerPacks.LineShape();
this.RockWeatherLab = new System.Windows.Forms.Label();
this.SourceSinkTab = new System.Windows.Forms.TabPage();
this.SinkinessTB = new System.Windows.Forms.TextBox();
this.SinkinessLab = new System.Windows.Forms.Label();
this.YSourceTB = new System.Windows.Forms.TextBox();
this.YSourceLab = new System.Windows.Forms.Label();
this.XSourceTB = new System.Windows.Forms.TextBox();
this.XSourceLab = new System.Windows.Forms.Label();
this.ColSourceTick = new System.Windows.Forms.CheckBox();
this.ColSourceLab = new System.Windows.Forms.Label();
this.YSinkTB = new System.Windows.Forms.TextBox();
this.YSinkLab = new System.Windows.Forms.Label();
this.XSinkTB = new System.Windows.Forms.TextBox();
this.XSinkLab = new System.Windows.Forms.Label();
this.ColSinkTick = new System.Windows.Forms.CheckBox();
this.ColSinkLab = new System.Windows.Forms.Label();
this.SinkTick = new System.Windows.Forms.CheckBox();
this.SinkTickLab = new System.Windows.Forms.Label();
this.SourceTick = new System.Windows.Forms.CheckBox();
this.SourceTickLab = new System.Windows.Forms.Label();
this.NumSinkTB = new System.Windows.Forms.TextBox();
this.NumSinkLab = new System.Windows.Forms.Label();
this.SinksTab = new System.Windows.Forms.Label();
this.SourcesTab = new System.Windows.Forms.Label();
this.NumSourceTB = new System.Windows.Forms.TextBox();
this.NumSourceLab = new System.Windows.Forms.Label();
this.shapeContainer4 = new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
this.lineShape5 = new Microsoft.VisualBasic.PowerPacks.LineShape();
this.Outputs = new System.Windows.Forms.TabPage();
this.RunLengthTB = new System.Windows.Forms.TextBox();
this.RunLengthLab = new System.Windows.Forms.Label();
this.OutputNameTB = new System.Windows.Forms.TextBox();
this.OutputNameLab = new System.Windows.Forms.Label();
this.SaveFreqTB = new System.Windows.Forms.TextBox();
this.SaveFreqLab = new System.Windows.Forms.Label();
this.CoordTT = new System.Windows.Forms.ToolTip(this.components);
this.SeeTabsButton = new System.Windows.Forms.Button();
this.zoomPanImageBox1 = new Smallwisdom.Windows.Forms.ZoomPanImageBox();
((System.ComponentModel.ISupportInitialize)(this.InfoStatusPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.IterationStatusPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.TimeStatusPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.QwStatusPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.QsStatusPanel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.waveAnglePanel)).BeginInit();
this.UpdateGraphPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.Graphic_ContrastSlider.SuspendLayout();
this.ZoomSlider.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit();
this.DescriptionTab.SuspendLayout();
this.WaveTab.SuspendLayout();
this.DEMTab.SuspendLayout();
this.MainWindowTabs.SuspendLayout();
this.TideTab.SuspendLayout();
this.ErosionTab.SuspendLayout();
this.SourceSinkTab.SuspendLayout();
this.Outputs.SuspendLayout();
this.SuspendLayout();
//
// loadDataButton
//
this.loadDataButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.loadDataButton.Location = new System.Drawing.Point(6, 291);
this.loadDataButton.Name = "loadDataButton";
this.loadDataButton.Size = new System.Drawing.Size(100, 24);
this.loadDataButton.TabIndex = 7;
this.loadDataButton.Text = "Load Data";
this.loadDataButton.Click += new System.EventHandler(this.loadDataButton_Click);
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemFile,
this.menuItemGraphics});
//
// menuItemFile
//
this.menuItemFile.Index = 0;
this.menuItemFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemFileOpen,
this.menuItemFileSaveAs,
this.menuItemFileSave});
this.menuItemFile.Text = "FILE";
//
// menuItemFileOpen
//
this.menuItemFileOpen.Index = 0;
this.menuItemFileOpen.Text = "Open";
this.menuItemFileOpen.Click += new System.EventHandler(this.menuItemFileOpen_Click);
//
// menuItemFileSaveAs
//
this.menuItemFileSaveAs.Index = 1;
this.menuItemFileSaveAs.Text = "Save As";
this.menuItemFileSaveAs.Click += new System.EventHandler(this.menuItemFileSave_Click);
//
// menuItemFileSave
//
this.menuItemFileSave.Index = 2;
this.menuItemFileSave.Text = "Save";
this.menuItemFileSave.Click += new System.EventHandler(this.menuItemFileSave_Click);
//
// menuItemGraphics
//
this.menuItemGraphics.Index = 1;
this.menuItemGraphics.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemGraphicsRock,
this.menuItemGraphicsSand,
this.menuItemGraphicsXY,
this.menuItemGraphicInitialXY,
this.menuItemGraphicDepth,
this.menuItemGraphicVolume,
this.menuItemShadow});
this.menuItemGraphics.Text = "GRAPHICS";
//
// menuItemGraphicsRock
//
this.menuItemGraphicsRock.Index = 0;
this.menuItemGraphicsRock.Text = "Ero / Depo";
this.menuItemGraphicsRock.Click += new System.EventHandler(this.menuItemGraphicsRock_Click);
//
// menuItemGraphicsSand
//
this.menuItemGraphicsSand.Checked = true;
this.menuItemGraphicsSand.Index = 1;
this.menuItemGraphicsSand.Text = "Sand";
this.menuItemGraphicsSand.Click += new System.EventHandler(this.menuItemGraphicsSand_Click);
//
// menuItemGraphicsXY
//
this.menuItemGraphicsXY.Checked = true;
this.menuItemGraphicsXY.Index = 2;
this.menuItemGraphicsXY.Text = "XY Coastline";
this.menuItemGraphicsXY.Click += new System.EventHandler(this.menuItemGraphicsXY_Click);
//
// menuItemGraphicInitialXY
//
this.menuItemGraphicInitialXY.Index = 3;
this.menuItemGraphicInitialXY.Text = "Initial XY";
this.menuItemGraphicInitialXY.Click += new System.EventHandler(this.menuItemGraphicInitialXY_Click);
//
// menuItemGraphicDepth
//
this.menuItemGraphicDepth.Enabled = false;
this.menuItemGraphicDepth.Index = 4;
this.menuItemGraphicDepth.Text = "Depth";
this.menuItemGraphicDepth.Click += new System.EventHandler(this.menuItemGraphicDepth_Click);
//
// menuItemGraphicVolume
//
this.menuItemGraphicVolume.Checked = true;
this.menuItemGraphicVolume.Index = 5;
this.menuItemGraphicVolume.Text = "Volume";
this.menuItemGraphicVolume.Click += new System.EventHandler(this.menuItemGraphicVolume_Click);
//
// menuItemShadow
//
this.menuItemShadow.Index = 6;
this.menuItemShadow.Text = "Shadow";
this.menuItemShadow.Click += new System.EventHandler(this.menuItemShadow_Click);
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 343);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.InfoStatusPanel,
this.IterationStatusPanel,
this.TimeStatusPanel,
this.QwStatusPanel,
this.QsStatusPanel,
this.waveAnglePanel});
this.statusBar1.ShowPanels = true;
this.statusBar1.Size = new System.Drawing.Size(1088, 19);
this.statusBar1.SizingGrip = false;
this.statusBar1.TabIndex = 144;
this.statusBar1.Text = "statusBar1";
this.statusBar1.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler(this.statusBar1_PanelClick);
//
// InfoStatusPanel
//
this.InfoStatusPanel.Name = "InfoStatusPanel";
this.InfoStatusPanel.Text = "info";
this.InfoStatusPanel.Width = 200;
//
// IterationStatusPanel
//
this.IterationStatusPanel.Name = "IterationStatusPanel";
this.IterationStatusPanel.Text = "iterations";
this.IterationStatusPanel.Width = 120;
//
// TimeStatusPanel
//
this.TimeStatusPanel.Name = "TimeStatusPanel";
this.TimeStatusPanel.Text = "time";
this.TimeStatusPanel.Width = 120;
//
// QwStatusPanel
//
this.QwStatusPanel.Name = "QwStatusPanel";
this.QwStatusPanel.Text = "Qw";
this.QwStatusPanel.Width = 120;
//
// QsStatusPanel
//
this.QsStatusPanel.Name = "QsStatusPanel";
this.QsStatusPanel.Text = "Qs";
this.QsStatusPanel.Width = 120;
//
// waveAnglePanel
//
this.waveAnglePanel.Name = "waveAnglePanel";
this.waveAnglePanel.Text = "Wave Angle";
//
// startButton
//
this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.startButton.Location = new System.Drawing.Point(112, 291);
this.startButton.Name = "startButton";
this.startButton.Size = new System.Drawing.Size(88, 24);
this.startButton.TabIndex = 146;
this.startButton.Text = "Start!";
this.startButton.Visible = false;
this.startButton.Click += new System.EventHandler(this.main_loop);
//
// quitSaveButton
//
this.quitSaveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.quitSaveButton.Location = new System.Drawing.Point(341, 291);
this.quitSaveButton.Name = "quitSaveButton";
this.quitSaveButton.Size = new System.Drawing.Size(100, 24);
this.quitSaveButton.TabIndex = 147;
this.quitSaveButton.Text = "Quit and Save";
this.quitSaveButton.Visible = false;
this.quitSaveButton.Click += new System.EventHandler(this.quitSaveButton_Click);
//
// updateGraphicsButton
//
this.updateGraphicsButton.Location = new System.Drawing.Point(3, 4);
this.updateGraphicsButton.Name = "updateGraphicsButton";
this.updateGraphicsButton.Size = new System.Drawing.Size(112, 40);
this.updateGraphicsButton.TabIndex = 144;
this.updateGraphicsButton.Text = "Update Graphics";
this.updateGraphicsButton.Click += new System.EventHandler(this.updateGraphics_Click_1);
//
// UpdateGraphPanel
//
this.UpdateGraphPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.UpdateGraphPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.UpdateGraphPanel.Controls.Add(this.SandOutputButton);
this.UpdateGraphPanel.Controls.Add(this.updateGraphicsButton);
this.UpdateGraphPanel.Location = new System.Drawing.Point(8, 239);
this.UpdateGraphPanel.Name = "UpdateGraphPanel";
this.UpdateGraphPanel.Size = new System.Drawing.Size(854, 45);
this.UpdateGraphPanel.TabIndex = 145;
this.UpdateGraphPanel.Visible = false;
//
// SandOutputButton
//
this.SandOutputButton.Location = new System.Drawing.Point(121, 4);
this.SandOutputButton.Name = "SandOutputButton";
this.SandOutputButton.Size = new System.Drawing.Size(112, 40);
this.SandOutputButton.TabIndex = 145;
this.SandOutputButton.Text = "PercentFullSand Output";
this.SandOutputButton.Click += new System.EventHandler(this.SandOutputButton_Click);
//
// ViewTabsCheck
//
this.ViewTabsCheck.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.ViewTabsCheck.AutoSize = true;
this.ViewTabsCheck.Checked = true;
this.ViewTabsCheck.CheckState = System.Windows.Forms.CheckState.Checked;
this.ViewTabsCheck.Location = new System.Drawing.Point(455, 469);
this.ViewTabsCheck.Name = "ViewTabsCheck";
this.ViewTabsCheck.Size = new System.Drawing.Size(82, 17);
this.ViewTabsCheck.TabIndex = 151;
this.ViewTabsCheck.Text = "View Tabs?";
this.ViewTabsCheck.UseVisualStyleBackColor = true;
//
// trackBar1
//
this.trackBar1.AutoSize = false;
this.trackBar1.Location = new System.Drawing.Point(54, 9);
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(104, 20);
this.trackBar1.TabIndex = 149;
this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
//
// Graphic_ContrastSlider
//
this.Graphic_ContrastSlider.Controls.Add(this.ContrastLab);
this.Graphic_ContrastSlider.Controls.Add(this.trackBar1);
this.Graphic_ContrastSlider.Location = new System.Drawing.Point(8, -3);
this.Graphic_ContrastSlider.Name = "Graphic_ContrastSlider";
this.Graphic_ContrastSlider.Size = new System.Drawing.Size(164, 35);
this.Graphic_ContrastSlider.TabIndex = 151;
this.Graphic_ContrastSlider.TabStop = false;
this.Graphic_ContrastSlider.Visible = false;
//
// ContrastLab
//
this.ContrastLab.AutoSize = true;
this.ContrastLab.Location = new System.Drawing.Point(8, 14);
this.ContrastLab.Name = "ContrastLab";
this.ContrastLab.Size = new System.Drawing.Size(46, 13);
this.ContrastLab.TabIndex = 152;
this.ContrastLab.Text = "Contrast";
//
// ZoomSlider
//
this.ZoomSlider.Controls.Add(this.ZoomLab);
this.ZoomSlider.Controls.Add(this.trackBar2);
this.ZoomSlider.Location = new System.Drawing.Point(176, -3);
this.ZoomSlider.Name = "ZoomSlider";
this.ZoomSlider.Size = new System.Drawing.Size(156, 35);
this.ZoomSlider.TabIndex = 152;
this.ZoomSlider.TabStop = false;
this.ZoomSlider.Visible = false;
//
// ZoomLab
//
this.ZoomLab.AutoSize = true;
this.ZoomLab.Location = new System.Drawing.Point(8, 13);
this.ZoomLab.Name = "ZoomLab";
this.ZoomLab.Size = new System.Drawing.Size(34, 13);
this.ZoomLab.TabIndex = 154;
this.ZoomLab.Text = "Zoom";
//
// trackBar2
//
this.trackBar2.AutoSize = false;
this.trackBar2.Location = new System.Drawing.Point(44, 9);
this.trackBar2.Minimum = 1;
this.trackBar2.Name = "trackBar2";
this.trackBar2.Size = new System.Drawing.Size(104, 20);
this.trackBar2.TabIndex = 153;
this.trackBar2.Value = 5;
this.trackBar2.Scroll += new System.EventHandler(this.trackBar2_Scroll);
//
// pauseButton
//
this.pauseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.pauseButton.Location = new System.Drawing.Point(206, 291);
this.pauseButton.Name = "pauseButton";
this.pauseButton.Size = new System.Drawing.Size(66, 24);
this.pauseButton.TabIndex = 153;
this.pauseButton.Text = "Pause";
this.pauseButton.UseVisualStyleBackColor = true;
this.pauseButton.Visible = false;
this.pauseButton.Click += new System.EventHandler(this.pauseButton_Click);
//
// resumeButton
//
this.resumeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.resumeButton.Location = new System.Drawing.Point(278, 291);
this.resumeButton.Name = "resumeButton";
this.resumeButton.Size = new System.Drawing.Size(57, 24);
this.resumeButton.TabIndex = 154;
this.resumeButton.Text = "Resume";
this.resumeButton.UseVisualStyleBackColor = true;
this.resumeButton.Visible = false;
this.resumeButton.Click += new System.EventHandler(this.resumeButton_Click);
//
// DescriptionTab
//
this.DescriptionTab.BackColor = System.Drawing.Color.White;
this.DescriptionTab.Controls.Add(this.DescripTB);
this.DescriptionTab.Location = new System.Drawing.Point(4, 22);
this.DescriptionTab.Name = "DescriptionTab";
this.DescriptionTab.Size = new System.Drawing.Size(1027, 255);
this.DescriptionTab.TabIndex = 5;
this.DescriptionTab.Text = "Description";
//
// DescripTB
//
this.DescripTB.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.DescripTB.Location = new System.Drawing.Point(9, 9);
this.DescripTB.Multiline = true;
this.DescripTB.Name = "DescripTB";
this.DescripTB.Size = new System.Drawing.Size(825, 221);
this.DescripTB.TabIndex = 0;
//
// WaveTab
//
this.WaveTab.BackColor = System.Drawing.SystemColors.Control;
this.WaveTab.Controls.Add(this.AsymTB);
this.WaveTab.Controls.Add(this.HighTB);
this.WaveTab.Controls.Add(this.AsymLab);
this.WaveTab.Controls.Add(this.HighLab);
this.WaveTab.Controls.Add(this.label2);
this.WaveTab.Controls.Add(this.UALab);
this.WaveTab.Controls.Add(this.UA_WaveTick);
this.WaveTab.Controls.Add(this.label1);
this.WaveTab.Controls.Add(this.WaveBrowseButton);
this.WaveTab.Controls.Add(this.WaveFileTB);
this.WaveTab.Controls.Add(this.WPLoadTB);
this.WaveTab.Controls.Add(this.WALoadTB);
this.WaveTab.Controls.Add(this.WHLoadTB);
this.WaveTab.Controls.Add(this.WPeriodTB);
this.WaveTab.Controls.Add(this.WAngleTB);
this.WaveTab.Controls.Add(this.WHeightTB);
this.WaveTab.Controls.Add(this.WPLoadLab);
this.WaveTab.Controls.Add(this.WALoadLab);
this.WaveTab.Controls.Add(this.WHLoadLab);
this.WaveTab.Controls.Add(this.ManWavLabel);
this.WaveTab.Controls.Add(this.ManWavTick);
this.WaveTab.Controls.Add(this.WavSourceTitle);
this.WaveTab.Controls.Add(this.ManWavTitle);
this.WaveTab.Controls.Add(this.LoadWaveTitle);
this.WaveTab.Controls.Add(this.BinnedLabel);
this.WaveTab.Controls.Add(this.BinnedTick);
this.WaveTab.Controls.Add(this.WaveTickLabel);
this.WaveTab.Controls.Add(this.WaveFileTick);
this.WaveTab.Controls.Add(this.WPeriodLabel);
this.WaveTab.Controls.Add(this.WAngleLabel);
this.WaveTab.Controls.Add(this.WHeightLabel);
this.WaveTab.Controls.Add(this.WaveFileLabel);
this.WaveTab.Controls.Add(this.shapeContainer2);
this.WaveTab.Location = new System.Drawing.Point(4, 22);
this.WaveTab.Name = "WaveTab";
this.WaveTab.Padding = new System.Windows.Forms.Padding(3);
this.WaveTab.Size = new System.Drawing.Size(1027, 255);
this.WaveTab.TabIndex = 10;
this.WaveTab.Text = "Wave Climate";
//
// AsymTB
//
this.AsymTB.Location = new System.Drawing.Point(418, 193);
this.AsymTB.Name = "AsymTB";
this.AsymTB.Size = new System.Drawing.Size(120, 20);
this.AsymTB.TabIndex = 193;
this.AsymTB.Text = "-9999";
//
// HighTB
//
this.HighTB.Location = new System.Drawing.Point(418, 230);
this.HighTB.Name = "HighTB";
this.HighTB.Size = new System.Drawing.Size(120, 20);
this.HighTB.TabIndex = 192;
this.HighTB.Text = "-9999";
//
// AsymLab
//
this.AsymLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.AsymLab.ForeColor = System.Drawing.SystemColors.ControlText;
this.AsymLab.Location = new System.Drawing.Point(280, 190);
this.AsymLab.Name = "AsymLab";
this.AsymLab.Size = new System.Drawing.Size(132, 24);
this.AsymLab.TabIndex = 191;
this.AsymLab.Text = "Wave Asymmetry (%):";
this.AsymLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// HighLab
//
this.HighLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.HighLab.ForeColor = System.Drawing.SystemColors.ControlText;
this.HighLab.Location = new System.Drawing.Point(283, 227);
this.HighLab.Name = "HighLab";
this.HighLab.Size = new System.Drawing.Size(129, 24);
this.HighLab.TabIndex = 190;
this.HighLab.Text = "Wave Highness (%):";
this.HighLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label2
//
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))));
this.label2.ForeColor = System.Drawing.SystemColors.ControlText;
this.label2.Location = new System.Drawing.Point(183, 131);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(34, 18);
this.label2.TabIndex = 189;
this.label2.Text = "OR";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// UALab
//
this.UALab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.UALab.ForeColor = System.Drawing.SystemColors.ControlText;
this.UALab.Location = new System.Drawing.Point(25, 96);
this.UALab.Name = "UALab";
this.UALab.Size = new System.Drawing.Size(189, 32);
this.UALab.TabIndex = 188;
this.UALab.Text = "Wave Asymmetry and Highness";
this.UALab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// UA_WaveTick
//
this.UA_WaveTick.Checked = true;
this.UA_WaveTick.CheckState = System.Windows.Forms.CheckState.Checked;
this.UA_WaveTick.Location = new System.Drawing.Point(220, 105);
this.UA_WaveTick.Name = "UA_WaveTick";
this.UA_WaveTick.Size = new System.Drawing.Size(15, 14);
this.UA_WaveTick.TabIndex = 187;
this.UA_WaveTick.UseVisualStyleBackColor = true;
this.UA_WaveTick.CheckedChanged += new System.EventHandler(this.UA_WaveTickTick_CheckedChanged);
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))));
this.label1.ForeColor = System.Drawing.SystemColors.GrayText;
this.label1.Location = new System.Drawing.Point(180, 76);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(34, 18);
this.label1.TabIndex = 186;
this.label1.Text = "OR";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// WaveBrowseButton
//
this.WaveBrowseButton.Enabled = false;
this.WaveBrowseButton.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.WaveBrowseButton.Location = new System.Drawing.Point(833, 58);
this.WaveBrowseButton.Name = "WaveBrowseButton";
this.WaveBrowseButton.Size = new System.Drawing.Size(54, 20);
this.WaveBrowseButton.TabIndex = 105;
this.WaveBrowseButton.Text = "Browse";
this.WaveBrowseButton.UseVisualStyleBackColor = true;
this.WaveBrowseButton.Click += new System.EventHandler(this.WaveBrowseButton_Click);
//
// WaveFileTB
//
this.WaveFileTB.BackColor = System.Drawing.SystemColors.Control;
this.WaveFileTB.Location = new System.Drawing.Point(716, 59);
this.WaveFileTB.Name = "WaveFileTB";
this.WaveFileTB.ReadOnly = true;
this.WaveFileTB.Size = new System.Drawing.Size(120, 20);
this.WaveFileTB.TabIndex = 104;
this.WaveFileTB.Text = "WaveClimate_1.dat";
//
// WPLoadTB
//
this.WPLoadTB.Enabled = false;
this.WPLoadTB.Location = new System.Drawing.Point(716, 135);
this.WPLoadTB.Name = "WPLoadTB";
this.WPLoadTB.ReadOnly = true;
this.WPLoadTB.Size = new System.Drawing.Size(120, 20);
this.WPLoadTB.TabIndex = 185;
this.WPLoadTB.Text = "6.65";
//
// WALoadTB
//
this.WALoadTB.Enabled = false;
this.WALoadTB.Location = new System.Drawing.Point(716, 98);
this.WALoadTB.Name = "WALoadTB";
this.WALoadTB.ReadOnly = true;
this.WALoadTB.Size = new System.Drawing.Size(120, 20);
this.WALoadTB.TabIndex = 184;
this.WALoadTB.Text = "67.5";
//
// WHLoadTB
//
this.WHLoadTB.Enabled = false;
this.WHLoadTB.Location = new System.Drawing.Point(716, 172);
this.WHLoadTB.Name = "WHLoadTB";
this.WHLoadTB.ReadOnly = true;
this.WHLoadTB.Size = new System.Drawing.Size(120, 20);
this.WHLoadTB.TabIndex = 183;
this.WHLoadTB.Text = "1.85";
//
// WPeriodTB
//
this.WPeriodTB.Enabled = false;
this.WPeriodTB.Location = new System.Drawing.Point(418, 96);
this.WPeriodTB.Name = "WPeriodTB";
this.WPeriodTB.ReadOnly = true;
this.WPeriodTB.Size = new System.Drawing.Size(120, 20);
this.WPeriodTB.TabIndex = 159;
this.WPeriodTB.Text = "7.3";
//
// WAngleTB
//
this.WAngleTB.Enabled = false;
this.WAngleTB.Location = new System.Drawing.Point(418, 59);
this.WAngleTB.Name = "WAngleTB";
this.WAngleTB.ReadOnly = true;
this.WAngleTB.Size = new System.Drawing.Size(120, 20);
this.WAngleTB.TabIndex = 158;
this.WAngleTB.Text = "45";
//
// WHeightTB
//
this.WHeightTB.Enabled = false;
this.WHeightTB.Location = new System.Drawing.Point(418, 133);
this.WHeightTB.Name = "WHeightTB";
this.WHeightTB.ReadOnly = true;
this.WHeightTB.Size = new System.Drawing.Size(120, 20);
this.WHeightTB.TabIndex = 157;
this.WHeightTB.Text = "0.9";
//
// WPLoadLab
//
this.WPLoadLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.WPLoadLab.Location = new System.Drawing.Point(606, 131);
this.WPLoadLab.Name = "WPLoadLab";
this.WPLoadLab.Size = new System.Drawing.Size(104, 24);
this.WPLoadLab.TabIndex = 182;
this.WPLoadLab.Text = "Wave Period:";
this.WPLoadLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// WALoadLab
//
this.WALoadLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.WALoadLab.Location = new System.Drawing.Point(606, 96);
this.WALoadLab.Name = "WALoadLab";
this.WALoadLab.Size = new System.Drawing.Size(104, 20);
this.WALoadLab.TabIndex = 181;
this.WALoadLab.Text = "Wave Angle:";
this.WALoadLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// WHLoadLab
//
this.WHLoadLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.WHLoadLab.Location = new System.Drawing.Point(606, 168);
this.WHLoadLab.Name = "WHLoadLab";
this.WHLoadLab.Size = new System.Drawing.Size(104, 24);
this.WHLoadLab.TabIndex = 180;
this.WHLoadLab.Text = "Wave Height:";
this.WHLoadLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// ManWavLabel
//
this.ManWavLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.ManWavLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.ManWavLabel.Location = new System.Drawing.Point(28, 40);
this.ManWavLabel.Name = "ManWavLabel";
this.ManWavLabel.Size = new System.Drawing.Size(189, 32);
this.ManWavLabel.TabIndex = 179;
this.ManWavLabel.Text = "Manual Entry";
this.ManWavLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// ManWavTick
//
this.ManWavTick.Location = new System.Drawing.Point(223, 51);
this.ManWavTick.Name = "ManWavTick";
this.ManWavTick.Size = new System.Drawing.Size(15, 14);
this.ManWavTick.TabIndex = 178;
this.ManWavTick.UseVisualStyleBackColor = true;
this.ManWavTick.CheckedChanged += new System.EventHandler(this.ManWavTick_CheckedChanged);
//
// WavSourceTitle
//
this.WavSourceTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))));
this.WavSourceTitle.Location = new System.Drawing.Point(34, 10);
this.WavSourceTitle.Name = "WavSourceTitle";
this.WavSourceTitle.Size = new System.Drawing.Size(226, 32);
this.WavSourceTitle.TabIndex = 177;
this.WavSourceTitle.Text = "Wave Climate Source";
this.WavSourceTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// ManWavTitle
//
this.ManWavTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))));
this.ManWavTitle.Location = new System.Drawing.Point(308, 10);
this.ManWavTitle.Name = "ManWavTitle";
this.ManWavTitle.Size = new System.Drawing.Size(268, 32);
this.ManWavTitle.TabIndex = 176;
this.ManWavTitle.Text = "Enter Wave Climate";
this.ManWavTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// LoadWaveTitle
//
this.LoadWaveTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))));
this.LoadWaveTitle.Location = new System.Drawing.Point(597, 10);
this.LoadWaveTitle.Name = "LoadWaveTitle";
this.LoadWaveTitle.Size = new System.Drawing.Size(311, 32);
this.LoadWaveTitle.TabIndex = 175;
this.LoadWaveTitle.Text = "Load Wave File";
this.LoadWaveTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// BinnedLabel
//
this.BinnedLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))));
this.BinnedLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.BinnedLabel.Location = new System.Drawing.Point(25, 186);
this.BinnedLabel.Name = "BinnedLabel";
this.BinnedLabel.Size = new System.Drawing.Size(189, 32);
this.BinnedLabel.TabIndex = 155;
this.BinnedLabel.Text = "Binned Wave Climate File";
this.BinnedLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.BinnedLabel.Visible = false;
//
// BinnedTick
//
this.BinnedTick.Enabled = false;
this.BinnedTick.Location = new System.Drawing.Point(220, 196);
this.BinnedTick.Name = "BinnedTick";
this.BinnedTick.Size = new System.Drawing.Size(15, 14);
this.BinnedTick.TabIndex = 154;
this.BinnedTick.UseVisualStyleBackColor = true;
this.BinnedTick.Visible = false;
//
// WaveTickLabel
//
this.WaveTickLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.WaveTickLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.WaveTickLabel.Location = new System.Drawing.Point(25, 149);
this.WaveTickLabel.Name = "WaveTickLabel";
this.WaveTickLabel.Size = new System.Drawing.Size(189, 32);
this.WaveTickLabel.TabIndex = 153;
this.WaveTickLabel.Text = "Load Wave Climate from File";
this.WaveTickLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// WaveFileTick
//
this.WaveFileTick.Location = new System.Drawing.Point(220, 159);
this.WaveFileTick.Name = "WaveFileTick";
this.WaveFileTick.Size = new System.Drawing.Size(15, 14);
this.WaveFileTick.TabIndex = 152;
this.WaveFileTick.UseVisualStyleBackColor = true;
this.WaveFileTick.CheckedChanged += new System.EventHandler(this.WaveFileTick_CheckedChanged);
//
// WPeriodLabel
//
this.WPeriodLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.WPeriodLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.WPeriodLabel.Location = new System.Drawing.Point(308, 93);
this.WPeriodLabel.Name = "WPeriodLabel";
this.WPeriodLabel.Size = new System.Drawing.Size(104, 24);
this.WPeriodLabel.TabIndex = 110;
this.WPeriodLabel.Text = "Wave Period:";
this.WPeriodLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// WAngleLabel
//
this.WAngleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.WAngleLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.WAngleLabel.Location = new System.Drawing.Point(308, 58);
this.WAngleLabel.Name = "WAngleLabel";
this.WAngleLabel.Size = new System.Drawing.Size(104, 20);
this.WAngleLabel.TabIndex = 108;
this.WAngleLabel.Text = "Wave Angle:";
this.WAngleLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// WHeightLabel
//
this.WHeightLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.WHeightLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.WHeightLabel.Location = new System.Drawing.Point(308, 130);
this.WHeightLabel.Name = "WHeightLabel";
this.WHeightLabel.Size = new System.Drawing.Size(104, 24);
this.WHeightLabel.TabIndex = 106;
this.WHeightLabel.Text = "Wave Height:";
this.WHeightLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// WaveFileLabel
//
this.WaveFileLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.WaveFileLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.WaveFileLabel.Location = new System.Drawing.Point(590, 56);
this.WaveFileLabel.Name = "WaveFileLabel";
this.WaveFileLabel.Size = new System.Drawing.Size(120, 24);
this.WaveFileLabel.TabIndex = 103;
this.WaveFileLabel.Text = "Wave Climate File:";
this.WaveFileLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// shapeContainer2
//
this.shapeContainer2.Location = new System.Drawing.Point(3, 3);
this.shapeContainer2.Margin = new System.Windows.Forms.Padding(0);
this.shapeContainer2.Name = "shapeContainer2";
this.shapeContainer2.Shapes.AddRange(new Microsoft.VisualBasic.PowerPacks.Shape[] {
this.lineShape3,
this.lineShape2});
this.shapeContainer2.Size = new System.Drawing.Size(1021, 249);
this.shapeContainer2.TabIndex = 160;
this.shapeContainer2.TabStop = false;
//
// lineShape3
//
this.lineShape3.BorderColor = System.Drawing.SystemColors.ControlDarkDark;
this.lineShape3.Name = "lineShape3";
this.lineShape3.X1 = 574;
this.lineShape3.X2 = 574;
this.lineShape3.Y1 = 12;
this.lineShape3.Y2 = 279;
//
// lineShape2
//
this.lineShape2.BorderColor = System.Drawing.SystemColors.ControlDarkDark;
this.lineShape2.Name = "lineShape2";
this.lineShape2.X1 = 275;
this.lineShape2.X2 = 275;
this.lineShape2.Y1 = 11;
this.lineShape2.Y2 = 278;
//
// DEMTab
//
this.DEMTab.BackColor = System.Drawing.SystemColors.Control;
this.DEMTab.Controls.Add(this.label3);
this.DEMTab.Controls.Add(this.InitPertLab);
this.DEMTab.Controls.Add(this.InitPertTick);
this.DEMTab.Controls.Add(this.PertLab);
this.DEMTab.Controls.Add(this.PertTick);
this.DEMTab.Controls.Add(this.orText);
this.DEMTab.Controls.Add(this.DEMDimTitle);
this.DEMTab.Controls.Add(this.DEMSourceTitle);
this.DEMTab.Controls.Add(this.RowsTB);
this.DEMTab.Controls.Add(this.RowLabel);
this.DEMTab.Controls.Add(this.ColLabel);
this.DEMTab.Controls.Add(this.ColumnTB);
this.DEMTab.Controls.Add(this.BlockLabel);
this.DEMTab.Controls.Add(this.BlockTick);
this.DEMTab.Controls.Add(this.WigglyLabel);
this.DEMTab.Controls.Add(this.WigglyTick);
this.DEMTab.Controls.Add(this.NormLabel);
this.DEMTab.Controls.Add(this.NormTick);
this.DEMTab.Controls.Add(this.CompDEMLabel);
this.DEMTab.Controls.Add(this.CompDEMTick);
this.DEMTab.Controls.Add(this.DEMLabel);
this.DEMTab.Controls.Add(this.DEMTick);
this.DEMTab.Controls.Add(this.DEMBrowseButton);
this.DEMTab.Controls.Add(this.DEMTextBox);
this.DEMTab.Controls.Add(this.shapeContainer1);
this.DEMTab.Location = new System.Drawing.Point(4, 22);
this.DEMTab.Name = "DEMTab";
this.DEMTab.Size = new System.Drawing.Size(1027, 255);
this.DEMTab.TabIndex = 0;
this.DEMTab.Text = "DEM";
//
// label3
//
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F, System.Drawing.FontStyle.Italic);
this.label3.ForeColor = System.Drawing.SystemColors.GrayText;
this.label3.Location = new System.Drawing.Point(34, 126);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(155, 32);
this.label3.TabIndex = 185;
this.label3.Text = "Note: Computer Generated DEMs are not enabled in this version";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// InitPertLab
//
this.InitPertLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.InitPertLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.InitPertLab.Location = new System.Drawing.Point(186, 131);
this.InitPertLab.Name = "InitPertLab";
this.InitPertLab.Size = new System.Drawing.Size(101, 32);
this.InitPertLab.TabIndex = 184;
this.InitPertLab.Text = "Initial Pert:";
this.InitPertLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// InitPertTick
//
this.InitPertTick.Enabled = false;
this.InitPertTick.Location = new System.Drawing.Point(293, 141);
this.InitPertTick.Name = "InitPertTick";
this.InitPertTick.Size = new System.Drawing.Size(15, 14);
this.InitPertTick.TabIndex = 183;
this.InitPertTick.UseVisualStyleBackColor = true;
this.InitPertTick.CheckedChanged += new System.EventHandler(this.InitPertTick_CheckedChanged);
//
// PertLab
//
this.PertLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.PertLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.PertLab.Location = new System.Drawing.Point(186, 168);
this.PertLab.Name = "PertLab";
this.PertLab.Size = new System.Drawing.Size(101, 32);
this.PertLab.TabIndex = 182;
this.PertLab.Text = "Pert:";
this.PertLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// PertTick
//
this.PertTick.Enabled = false;
this.PertTick.Location = new System.Drawing.Point(293, 178);
this.PertTick.Name = "PertTick";
this.PertTick.Size = new System.Drawing.Size(15, 14);
this.PertTick.TabIndex = 181;
this.PertTick.UseVisualStyleBackColor = true;
this.PertTick.CheckedChanged += new System.EventHandler(this.PertTick_CheckedChanged);
//
// orText
//
this.orText.BackColor = System.Drawing.Color.Transparent;
this.orText.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))));
this.orText.ForeColor = System.Drawing.SystemColors.ControlText;
this.orText.Location = new System.Drawing.Point(155, 74);
this.orText.Name = "orText";
this.orText.Size = new System.Drawing.Size(34, 18);
this.orText.TabIndex = 177;
this.orText.Text = "OR";
this.orText.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// DEMDimTitle
//
this.DEMDimTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))));
this.DEMDimTitle.Location = new System.Drawing.Point(481, 6);
this.DEMDimTitle.Name = "DEMDimTitle";
this.DEMDimTitle.Size = new System.Drawing.Size(369, 32);
this.DEMDimTitle.TabIndex = 175;
this.DEMDimTitle.Text = "DEM Dimensions";
this.DEMDimTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// DEMSourceTitle
//
this.DEMSourceTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))));
this.DEMSourceTitle.Location = new System.Drawing.Point(9, 6);
this.DEMSourceTitle.Name = "DEMSourceTitle";
this.DEMSourceTitle.Size = new System.Drawing.Size(454, 32);
this.DEMSourceTitle.TabIndex = 174;
this.DEMSourceTitle.Text = "DEM Source";
this.DEMSourceTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// RowsTB
//
this.RowsTB.Location = new System.Drawing.Point(638, 86);
this.RowsTB.Name = "RowsTB";
this.RowsTB.ReadOnly = true;
this.RowsTB.Size = new System.Drawing.Size(142, 20);
this.RowsTB.TabIndex = 172;
this.RowsTB.Text = "200";
//
// RowLabel
//
this.RowLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.RowLabel.Location = new System.Drawing.Point(502, 79);
this.RowLabel.Name = "RowLabel";
this.RowLabel.Size = new System.Drawing.Size(130, 32);
this.RowLabel.TabIndex = 171;
this.RowLabel.Text = "Number of Rows:";
this.RowLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// ColLabel
//
this.ColLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
this.ColLabel.Location = new System.Drawing.Point(499, 41);
this.ColLabel.Name = "ColLabel";
this.ColLabel.Size = new System.Drawing.Size(133, 32);
this.ColLabel.TabIndex = 170;
this.ColLabel.Text = "Number of Columns:";
this.ColLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// ColumnTB
//
this.ColumnTB.Location = new System.Drawing.Point(638, 47);
this.ColumnTB.Name = "ColumnTB";
this.ColumnTB.ReadOnly = true;
this.ColumnTB.Size = new System.Drawing.Size(142, 20);
this.ColumnTB.TabIndex = 169;
this.ColumnTB.Text = "300";
//
// BlockLabel
//
this.BlockLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.BlockLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.BlockLabel.Location = new System.Drawing.Point(227, 241);
this.BlockLabel.Name = "BlockLabel";
this.BlockLabel.Size = new System.Drawing.Size(60, 32);
this.BlockLabel.TabIndex = 168;
this.BlockLabel.Text = "Block:";
this.BlockLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// BlockTick
//
this.BlockTick.Enabled = false;
this.BlockTick.Location = new System.Drawing.Point(293, 251);
this.BlockTick.Name = "BlockTick";
this.BlockTick.Size = new System.Drawing.Size(15, 14);
this.BlockTick.TabIndex = 167;
this.BlockTick.UseVisualStyleBackColor = true;
this.BlockTick.CheckedChanged += new System.EventHandler(this.BlockTick_CheckedChanged);
//
// WigglyLabel
//
this.WigglyLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.WigglyLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.WigglyLabel.Location = new System.Drawing.Point(227, 205);
this.WigglyLabel.Name = "WigglyLabel";
this.WigglyLabel.Size = new System.Drawing.Size(60, 32);
this.WigglyLabel.TabIndex = 166;
this.WigglyLabel.Text = "Wiggly:";
this.WigglyLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// WigglyTick
//
this.WigglyTick.Enabled = false;
this.WigglyTick.Location = new System.Drawing.Point(293, 215);
this.WigglyTick.Name = "WigglyTick";
this.WigglyTick.Size = new System.Drawing.Size(15, 14);
this.WigglyTick.TabIndex = 165;
this.WigglyTick.UseVisualStyleBackColor = true;
this.WigglyTick.CheckedChanged += new System.EventHandler(this.WigglyTick_CheckedChanged);
//
// NormLabel
//
this.NormLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.NormLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.NormLabel.Location = new System.Drawing.Point(227, 94);
this.NormLabel.Name = "NormLabel";
this.NormLabel.Size = new System.Drawing.Size(60, 32);
this.NormLabel.TabIndex = 164;
this.NormLabel.Text = "Normal:";
this.NormLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NormTick
//
this.NormTick.Enabled = false;
this.NormTick.Location = new System.Drawing.Point(293, 104);
this.NormTick.Name = "NormTick";
this.NormTick.Size = new System.Drawing.Size(15, 14);
this.NormTick.TabIndex = 163;
this.NormTick.UseVisualStyleBackColor = true;
this.NormTick.CheckedChanged += new System.EventHandler(this.NormTick_CheckedChanged);
//
// CompDEMLabel
//
this.CompDEMLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.CompDEMLabel.ForeColor = System.Drawing.SystemColors.GrayText;
this.CompDEMLabel.Location = new System.Drawing.Point(3, 94);
this.CompDEMLabel.Name = "CompDEMLabel";
this.CompDEMLabel.Size = new System.Drawing.Size(189, 32);
this.CompDEMLabel.TabIndex = 162;
this.CompDEMLabel.Text = "Computer Generated DEM";
this.CompDEMLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CompDEMTick
//
this.CompDEMTick.Enabled = false;
this.CompDEMTick.Location = new System.Drawing.Point(198, 104);
this.CompDEMTick.Name = "CompDEMTick";
this.CompDEMTick.Size = new System.Drawing.Size(15, 14);
this.CompDEMTick.TabIndex = 161;
this.CompDEMTick.UseVisualStyleBackColor = true;
this.CompDEMTick.CheckedChanged += new System.EventHandler(this.CompDEMTick_CheckedChanged);
//
// DEMLabel
//
this.DEMLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.DEMLabel.Location = new System.Drawing.Point(3, 40);
this.DEMLabel.Name = "DEMLabel";
this.DEMLabel.Size = new System.Drawing.Size(189, 32);
this.DEMLabel.TabIndex = 160;
this.DEMLabel.Text = "Load from DEM File";
this.DEMLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// DEMTick
//
this.DEMTick.Checked = true;
this.DEMTick.CheckState = System.Windows.Forms.CheckState.Checked;
this.DEMTick.Location = new System.Drawing.Point(198, 51);
this.DEMTick.Name = "DEMTick";
this.DEMTick.Size = new System.Drawing.Size(15, 14);
this.DEMTick.TabIndex = 159;
this.DEMTick.UseVisualStyleBackColor = true;
this.DEMTick.CheckedChanged += new System.EventHandler(this.DEMTick_CheckedChanged);
//
// DEMBrowseButton
//
this.DEMBrowseButton.Location = new System.Drawing.Point(385, 47);
this.DEMBrowseButton.Name = "DEMBrowseButton";
this.DEMBrowseButton.Size = new System.Drawing.Size(54, 20);
this.DEMBrowseButton.TabIndex = 102;
this.DEMBrowseButton.Text = "Browse";
this.DEMBrowseButton.UseVisualStyleBackColor = true;
this.DEMBrowseButton.Click += new System.EventHandler(this.DEMFileExplorer_Click);
//
// DEMTextBox
//
this.DEMTextBox.Location = new System.Drawing.Point(246, 47);
this.DEMTextBox.Name = "DEMTextBox";
this.DEMTextBox.Size = new System.Drawing.Size(142, 20);
this.DEMTextBox.TabIndex = 100;
this.DEMTextBox.Text = "Paper_coast_4.txt";
//
// shapeContainer1
//
this.shapeContainer1.Location = new System.Drawing.Point(0, 0);
this.shapeContainer1.Margin = new System.Windows.Forms.Padding(0);
this.shapeContainer1.Name = "shapeContainer1";
this.shapeContainer1.Shapes.AddRange(new Microsoft.VisualBasic.PowerPacks.Shape[] {
this.lineShape1});
this.shapeContainer1.Size = new System.Drawing.Size(1027, 255);
this.shapeContainer1.TabIndex = 173;
this.shapeContainer1.TabStop = false;
//
// lineShape1
//
this.lineShape1.BorderColor = System.Drawing.SystemColors.ControlDarkDark;
this.lineShape1.Name = "lineShape1";
this.lineShape1.X1 = 475;
this.lineShape1.X2 = 475;
this.lineShape1.Y1 = 14;
this.lineShape1.Y2 = 204;
//
// MainWindowTabs
//
this.MainWindowTabs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.MainWindowTabs.Controls.Add(this.DEMTab);
this.MainWindowTabs.Controls.Add(this.WaveTab);
this.MainWindowTabs.Controls.Add(this.TideTab);
this.MainWindowTabs.Controls.Add(this.ErosionTab);
this.MainWindowTabs.Controls.Add(this.SourceSinkTab);
this.MainWindowTabs.Controls.Add(this.Outputs);
this.MainWindowTabs.Controls.Add(this.DescriptionTab);
this.MainWindowTabs.Location = new System.Drawing.Point(8, 3);
this.MainWindowTabs.MinimumSize = new System.Drawing.Size(0, 269);
this.MainWindowTabs.Name = "MainWindowTabs";
this.MainWindowTabs.SelectedIndex = 0;
this.MainWindowTabs.Size = new System.Drawing.Size(1035, 281);
this.MainWindowTabs.TabIndex = 143;
//
// TideTab
//
this.TideTab.BackColor = System.Drawing.SystemColors.Control;
this.TideTab.Controls.Add(this.StepSLR_Lab);
this.TideTab.Controls.Add(this.StepSLR_Tick);
this.TideTab.Controls.Add(this.DoSLRLab);
this.TideTab.Controls.Add(this.DoSLRTick);
this.TideTab.Controls.Add(this.RateSLR_TB);
this.TideTab.Controls.Add(this.RateSLRLab);
this.TideTab.Controls.Add(this.SLR_TB);
this.TideTab.Controls.Add(this.SLRLab);
this.TideTab.Controls.Add(this.SLRTitle);
this.TideTab.Controls.Add(this.TidesTitle);
this.TideTab.Controls.Add(this.DoTidesLabel);
this.TideTab.Controls.Add(this.DoTidesTick);
this.TideTab.Controls.Add(this.HighTideTB);
this.TideTab.Controls.Add(this.HighTideLab);
this.TideTab.Controls.Add(this.LowTideTB);
this.TideTab.Controls.Add(this.LowTideLab);
this.TideTab.Controls.Add(this.shapeContainer5);
this.TideTab.Location = new System.Drawing.Point(4, 22);
this.TideTab.Name = "TideTab";
this.TideTab.Padding = new System.Windows.Forms.Padding(3);
this.TideTab.Size = new System.Drawing.Size(1027, 255);
this.TideTab.TabIndex = 11;
this.TideTab.Text = "Water Level";
//
// StepSLR_Lab
//
this.StepSLR_Lab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.StepSLR_Lab.ForeColor = System.Drawing.SystemColors.ControlText;
this.StepSLR_Lab.Location = new System.Drawing.Point(487, 94);
this.StepSLR_Lab.Name = "StepSLR_Lab";
this.StepSLR_Lab.Size = new System.Drawing.Size(136, 32);
this.StepSLR_Lab.TabIndex = 192;
this.StepSLR_Lab.Text = "Stepped SLR";
this.StepSLR_Lab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// StepSLR_Tick
//
this.StepSLR_Tick.Location = new System.Drawing.Point(629, 105);
this.StepSLR_Tick.Name = "StepSLR_Tick";
this.StepSLR_Tick.Size = new System.Drawing.Size(15, 14);
this.StepSLR_Tick.TabIndex = 191;
this.StepSLR_Tick.UseVisualStyleBackColor = true;
//
// DoSLRLab
//
this.DoSLRLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.DoSLRLab.ForeColor = System.Drawing.SystemColors.ControlText;
this.DoSLRLab.Location = new System.Drawing.Point(487, 53);
this.DoSLRLab.Name = "DoSLRLab";
this.DoSLRLab.Size = new System.Drawing.Size(136, 32);
this.DoSLRLab.TabIndex = 190;
this.DoSLRLab.Text = "Run With SLR";
this.DoSLRLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// DoSLRTick
//
this.DoSLRTick.Checked = true;
this.DoSLRTick.CheckState = System.Windows.Forms.CheckState.Checked;
this.DoSLRTick.Location = new System.Drawing.Point(629, 64);
this.DoSLRTick.Name = "DoSLRTick";
this.DoSLRTick.Size = new System.Drawing.Size(15, 14);
this.DoSLRTick.TabIndex = 189;
this.DoSLRTick.UseVisualStyleBackColor = true;
this.DoSLRTick.CheckedChanged += new System.EventHandler(this.DoSLRTick_CheckedChanged);
//
// RateSLR_TB
//
this.RateSLR_TB.Location = new System.Drawing.Point(629, 176);
this.RateSLR_TB.Name = "RateSLR_TB";
this.RateSLR_TB.Size = new System.Drawing.Size(120, 20);
this.RateSLR_TB.TabIndex = 188;
this.RateSLR_TB.Text = "3000";
//
// RateSLRLab
//
this.RateSLRLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.RateSLRLab.ForeColor = System.Drawing.SystemColors.ControlText;
this.RateSLRLab.Location = new System.Drawing.Point(465, 175);
this.RateSLRLab.Name = "RateSLRLab";
this.RateSLRLab.Size = new System.Drawing.Size(158, 20);
this.RateSLRLab.TabIndex = 187;
this.RateSLRLab.Text = "Rate of SLR (yrs):";
this.RateSLRLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// SLR_TB
//
this.SLR_TB.Location = new System.Drawing.Point(629, 139);
this.SLR_TB.Name = "SLR_TB";
this.SLR_TB.Size = new System.Drawing.Size(120, 20);
this.SLR_TB.TabIndex = 186;
this.SLR_TB.Text = "60";
//
// SLRLab
//
this.SLRLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.SLRLab.ForeColor = System.Drawing.SystemColors.ControlText;
this.SLRLab.Location = new System.Drawing.Point(482, 138);
this.SLRLab.Name = "SLRLab";
this.SLRLab.Size = new System.Drawing.Size(141, 20);
this.SLRLab.TabIndex = 185;
this.SLRLab.Text = "Sea Level Rise (m):";
this.SLRLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// SLRTitle
//
this.SLRTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))));
this.SLRTitle.Location = new System.Drawing.Point(440, 15);
this.SLRTitle.Name = "SLRTitle";
this.SLRTitle.Size = new System.Drawing.Size(380, 32);
this.SLRTitle.TabIndex = 183;
this.SLRTitle.Text = "Sea Level Rise";
this.SLRTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// TidesTitle
//
this.TidesTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))));
this.TidesTitle.Location = new System.Drawing.Point(32, 15);
this.TidesTitle.Name = "TidesTitle";
this.TidesTitle.Size = new System.Drawing.Size(371, 32);
this.TidesTitle.TabIndex = 182;
this.TidesTitle.Text = "Tides";
this.TidesTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// DoTidesLabel
//
this.DoTidesLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
this.DoTidesLabel.ForeColor = System.Drawing.SystemColors.ControlText;
this.DoTidesLabel.Location = new System.Drawing.Point(80, 54);
this.DoTidesLabel.Name = "DoTidesLabel";
this.DoTidesLabel.Size = new System.Drawing.Size(136, 32);
this.DoTidesLabel.TabIndex = 181;
this.DoTidesLabel.Text = "Run With Tides";
this.DoTidesLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// DoTidesTick
//
this.DoTidesTick.Checked = true;
this.DoTidesTick.CheckState = System.Windows.Forms.CheckState.Checked;
this.DoTidesTick.Location = new System.Drawing.Point(222, 65);
this.DoTidesTick.Name = "DoTidesTick";
this.DoTidesTick.Size = new System.Drawing.Size(15, 14);
this.DoTidesTick.TabIndex = 180;
this.DoTidesTick.UseVisualStyleBackColor = true;
this.DoTidesTick.CheckedChanged += new System.EventHandler(this.DoTidesTick_CheckedChanged);
//
// HighTideTB
//
this.HighTideTB.Location = new System.Drawing.Point(222, 138);
this.HighTideTB.Name = "HighTideTB";
this.HighTideTB.Size = new System.Drawing.Size(120, 20);
this.HighTideTB.TabIndex = 163;
this.HighTideTB.Text = "0";
//
// HighTideLab
//
this.HighTideLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.HighTideLab.ForeColor = System.Drawing.SystemColors.ControlText;
this.HighTideLab.Location = new System.Drawing.Point(83, 137);
this.HighTideLab.Name = "HighTideLab";
this.HighTideLab.Size = new System.Drawing.Size(133, 20);
this.HighTideLab.TabIndex = 162;
this.HighTideLab.Text = "High Tide (m):";
this.HighTideLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// LowTideTB
//
this.LowTideTB.Location = new System.Drawing.Point(222, 101);
this.LowTideTB.Name = "LowTideTB";
this.LowTideTB.Size = new System.Drawing.Size(120, 20);
this.LowTideTB.TabIndex = 159;
this.LowTideTB.Text = "0";
//
// LowTideLab
//
this.LowTideLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.LowTideLab.ForeColor = System.Drawing.SystemColors.ControlText;
this.LowTideLab.Location = new System.Drawing.Point(112, 100);
this.LowTideLab.Name = "LowTideLab";
this.LowTideLab.Size = new System.Drawing.Size(104, 20);
this.LowTideLab.TabIndex = 109;
this.LowTideLab.Text = "Low Tide (m):";
this.LowTideLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// shapeContainer5
//
this.shapeContainer5.Location = new System.Drawing.Point(3, 3);
this.shapeContainer5.Margin = new System.Windows.Forms.Padding(0);
this.shapeContainer5.Name = "shapeContainer5";
this.shapeContainer5.Shapes.AddRange(new Microsoft.VisualBasic.PowerPacks.Shape[] {
this.lineShape6});
this.shapeContainer5.Size = new System.Drawing.Size(1021, 249);
this.shapeContainer5.TabIndex = 184;
this.shapeContainer5.TabStop = false;
//
// lineShape6
//
this.lineShape6.BorderColor = System.Drawing.SystemColors.ControlDarkDark;
this.lineShape6.Name = "lineShape6";
this.lineShape6.X1 = 420;
this.lineShape6.X2 = 420;
this.lineShape6.Y1 = 38;
this.lineShape6.Y2 = 204;
//
// ErosionTab
//
this.ErosionTab.BackColor = System.Drawing.SystemColors.Control;
this.ErosionTab.Controls.Add(this.WeatheringTitle);
this.ErosionTab.Controls.Add(this.ErosionTitle);
this.ErosionTab.Controls.Add(this.RockWeatherTB);
this.ErosionTab.Controls.Add(this.PercentSlowTB);
this.ErosionTab.Controls.Add(this.PercentSlowLab);
this.ErosionTab.Controls.Add(this.PercentFastTB);
this.ErosionTab.Controls.Add(this.PercentFastLab);
this.ErosionTab.Controls.Add(this.FastWeatherTB);
this.ErosionTab.Controls.Add(this.FastWeatherLab);
this.ErosionTab.Controls.Add(this.SlowWeatherTB);
this.ErosionTab.Controls.Add(this.SlowWeatherLab);
this.ErosionTab.Controls.Add(this.ErosRateTB);
this.ErosionTab.Controls.Add(this.ErosRateLab);
this.ErosionTab.Controls.Add(this.shapeContainer3);
this.ErosionTab.Controls.Add(this.RockWeatherLab);
this.ErosionTab.Location = new System.Drawing.Point(4, 22);
this.ErosionTab.Name = "ErosionTab";
this.ErosionTab.Padding = new System.Windows.Forms.Padding(3);
this.ErosionTab.Size = new System.Drawing.Size(1027, 255);
this.ErosionTab.TabIndex = 12;
this.ErosionTab.Text = "Erosion & Weathering";
//
// WeatheringTitle
//
this.WeatheringTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))));
this.WeatheringTitle.Location = new System.Drawing.Point(440, 15);
this.WeatheringTitle.Name = "WeatheringTitle";
this.WeatheringTitle.Size = new System.Drawing.Size(380, 32);
this.WeatheringTitle.TabIndex = 178;
this.WeatheringTitle.Text = "Weathering";
this.WeatheringTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// ErosionTitle
//
this.ErosionTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))));
this.ErosionTitle.Location = new System.Drawing.Point(32, 15);
this.ErosionTitle.Name = "ErosionTitle";
this.ErosionTitle.Size = new System.Drawing.Size(371, 32);
this.ErosionTitle.TabIndex = 177;
this.ErosionTitle.Text = "Erosion";
this.ErosionTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// RockWeatherTB
//
this.RockWeatherTB.Location = new System.Drawing.Point(700, 64);
this.RockWeatherTB.Name = "RockWeatherTB";
this.RockWeatherTB.Size = new System.Drawing.Size(120, 20);
this.RockWeatherTB.TabIndex = 173;
this.RockWeatherTB.Text = "5.0";
//
// PercentSlowTB
//
this.PercentSlowTB.Location = new System.Drawing.Point(283, 149);
this.PercentSlowTB.Name = "PercentSlowTB";
this.PercentSlowTB.Size = new System.Drawing.Size(120, 20);
this.PercentSlowTB.TabIndex = 169;
this.PercentSlowTB.Text = "0.5";
//
// PercentSlowLab
//
this.PercentSlowLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.PercentSlowLab.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.PercentSlowLab.Location = new System.Drawing.Point(21, 148);
this.PercentSlowLab.Name = "PercentSlowLab";
this.PercentSlowLab.Size = new System.Drawing.Size(256, 20);
this.PercentSlowLab.TabIndex = 168;
this.PercentSlowLab.Text = "Percentage of Fine, Slow Eroding Material:";
this.PercentSlowLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// PercentFastTB
//
this.PercentFastTB.Location = new System.Drawing.Point(283, 106);
this.PercentFastTB.Name = "PercentFastTB";
this.PercentFastTB.Size = new System.Drawing.Size(120, 20);
this.PercentFastTB.TabIndex = 167;
this.PercentFastTB.Text = "0.5";
//
// PercentFastLab
//
this.PercentFastLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.PercentFastLab.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.PercentFastLab.Location = new System.Drawing.Point(29, 105);
this.PercentFastLab.Name = "PercentFastLab";
this.PercentFastLab.Size = new System.Drawing.Size(248, 20);
this.PercentFastLab.TabIndex = 166;
this.PercentFastLab.Text = "Percentage of Fine, Fast Eroding Material:";
this.PercentFastLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// FastWeatherTB
//
this.FastWeatherTB.Location = new System.Drawing.Point(700, 149);
this.FastWeatherTB.Name = "FastWeatherTB";
this.FastWeatherTB.Size = new System.Drawing.Size(120, 20);
this.FastWeatherTB.TabIndex = 165;
this.FastWeatherTB.Text = "1.5";
//
// FastWeatherLab
//
this.FastWeatherLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FastWeatherLab.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.FastWeatherLab.Location = new System.Drawing.Point(471, 148);
this.FastWeatherLab.Name = "FastWeatherLab";
this.FastWeatherLab.Size = new System.Drawing.Size(223, 20);
this.FastWeatherLab.TabIndex = 164;
this.FastWeatherLab.Text = "Fast Weathering Coefficient:";
this.FastWeatherLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// SlowWeatherTB
//
this.SlowWeatherTB.Location = new System.Drawing.Point(700, 106);
this.SlowWeatherTB.Name = "SlowWeatherTB";
this.SlowWeatherTB.Size = new System.Drawing.Size(120, 20);
this.SlowWeatherTB.TabIndex = 163;
this.SlowWeatherTB.Text = "0.125";
//
// SlowWeatherLab
//
this.SlowWeatherLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.SlowWeatherLab.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.SlowWeatherLab.Location = new System.Drawing.Point(468, 105);
this.SlowWeatherLab.Name = "SlowWeatherLab";
this.SlowWeatherLab.Size = new System.Drawing.Size(226, 20);
this.SlowWeatherLab.TabIndex = 162;
this.SlowWeatherLab.Text = "Slow Weathering Coefficient:";
this.SlowWeatherLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// ErosRateTB
//
this.ErosRateTB.Location = new System.Drawing.Point(283, 64);
this.ErosRateTB.Name = "ErosRateTB";
this.ErosRateTB.Size = new System.Drawing.Size(120, 20);
this.ErosRateTB.TabIndex = 161;
this.ErosRateTB.Text = "2";
//
// ErosRateLab
//
this.ErosRateLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ErosRateLab.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.ErosRateLab.Location = new System.Drawing.Point(93, 63);
this.ErosRateLab.Name = "ErosRateLab";
this.ErosRateLab.Size = new System.Drawing.Size(184, 20);
this.ErosRateLab.TabIndex = 160;
this.ErosRateLab.Text = "Erosion Rate Per Year (m):";
this.ErosRateLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// shapeContainer3
//
this.shapeContainer3.Location = new System.Drawing.Point(3, 3);
this.shapeContainer3.Margin = new System.Windows.Forms.Padding(0);
this.shapeContainer3.Name = "shapeContainer3";
this.shapeContainer3.Shapes.AddRange(new Microsoft.VisualBasic.PowerPacks.Shape[] {
this.lineShape4});
this.shapeContainer3.Size = new System.Drawing.Size(1021, 249);
this.shapeContainer3.TabIndex = 179;
this.shapeContainer3.TabStop = false;
//
// lineShape4
//
this.lineShape4.BorderColor = System.Drawing.SystemColors.ControlDarkDark;
this.lineShape4.Name = "lineShape4";
this.lineShape4.X1 = 420;
this.lineShape4.X2 = 420;
this.lineShape4.Y1 = 14;
this.lineShape4.Y2 = 180;
//
// RockWeatherLab
//
this.RockWeatherLab.BackColor = System.Drawing.Color.Transparent;
this.RockWeatherLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.RockWeatherLab.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.RockWeatherLab.Location = new System.Drawing.Point(427, 63);
this.RockWeatherLab.Name = "RockWeatherLab";
this.RockWeatherLab.Size = new System.Drawing.Size(267, 20);
this.RockWeatherLab.TabIndex = 172;
this.RockWeatherLab.Text = "Elevation that Rock Weathering Occurs (m):";
this.RockWeatherLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// SourceSinkTab
//
this.SourceSinkTab.BackColor = System.Drawing.SystemColors.Control;
this.SourceSinkTab.Controls.Add(this.SinkinessTB);
this.SourceSinkTab.Controls.Add(this.SinkinessLab);
this.SourceSinkTab.Controls.Add(this.YSourceTB);
this.SourceSinkTab.Controls.Add(this.YSourceLab);
this.SourceSinkTab.Controls.Add(this.XSourceTB);
this.SourceSinkTab.Controls.Add(this.XSourceLab);
this.SourceSinkTab.Controls.Add(this.ColSourceTick);
this.SourceSinkTab.Controls.Add(this.ColSourceLab);
this.SourceSinkTab.Controls.Add(this.YSinkTB);
this.SourceSinkTab.Controls.Add(this.YSinkLab);
this.SourceSinkTab.Controls.Add(this.XSinkTB);
this.SourceSinkTab.Controls.Add(this.XSinkLab);
this.SourceSinkTab.Controls.Add(this.ColSinkTick);
this.SourceSinkTab.Controls.Add(this.ColSinkLab);
this.SourceSinkTab.Controls.Add(this.SinkTick);
this.SourceSinkTab.Controls.Add(this.SinkTickLab);
this.SourceSinkTab.Controls.Add(this.SourceTick);
this.SourceSinkTab.Controls.Add(this.SourceTickLab);
this.SourceSinkTab.Controls.Add(this.NumSinkTB);
this.SourceSinkTab.Controls.Add(this.NumSinkLab);
this.SourceSinkTab.Controls.Add(this.SinksTab);
this.SourceSinkTab.Controls.Add(this.SourcesTab);
this.SourceSinkTab.Controls.Add(this.NumSourceTB);
this.SourceSinkTab.Controls.Add(this.NumSourceLab);
this.SourceSinkTab.Controls.Add(this.shapeContainer4);
this.SourceSinkTab.Location = new System.Drawing.Point(4, 22);
this.SourceSinkTab.Name = "SourceSinkTab";
this.SourceSinkTab.Padding = new System.Windows.Forms.Padding(3);
this.SourceSinkTab.Size = new System.Drawing.Size(1027, 255);
this.SourceSinkTab.TabIndex = 13;
this.SourceSinkTab.Text = "Sources & Sinks";
//
// SinkinessTB
//
this.SinkinessTB.Enabled = false;
this.SinkinessTB.Location = new System.Drawing.Point(582, 142);
this.SinkinessTB.Name = "SinkinessTB";
this.SinkinessTB.ReadOnly = true;
this.SinkinessTB.Size = new System.Drawing.Size(120, 20);
this.SinkinessTB.TabIndex = 201;
//
// SinkinessLab
//
this.SinkinessLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.SinkinessLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.SinkinessLab.Location = new System.Drawing.Point(441, 141);
this.SinkinessLab.Name = "SinkinessLab";
this.SinkinessLab.Size = new System.Drawing.Size(135, 20);
this.SinkinessLab.TabIndex = 200;
this.SinkinessLab.Text = "Sinkiness (%):";
this.SinkinessLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// YSourceTB
//
this.YSourceTB.Enabled = false;
this.YSourceTB.Location = new System.Drawing.Point(169, 177);
this.YSourceTB.Name = "YSourceTB";
this.YSourceTB.ReadOnly = true;
this.YSourceTB.Size = new System.Drawing.Size(235, 20);
this.YSourceTB.TabIndex = 199;
this.CoordTT.SetToolTip(this.YSourceTB, "Comma Seperated (e.g. 1, 2, 3, 4)");
//
// YSourceLab
//
this.YSourceLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.YSourceLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.YSourceLab.Location = new System.Drawing.Point(27, 176);
this.YSourceLab.Name = "YSourceLab";
this.YSourceLab.Size = new System.Drawing.Size(136, 20);
this.YSourceLab.TabIndex = 198;
this.YSourceLab.Text = "Y-Coordinate(s):";
this.YSourceLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// XSourceTB
//
this.XSourceTB.Enabled = false;
this.XSourceTB.Location = new System.Drawing.Point(169, 143);
this.XSourceTB.Name = "XSourceTB";
this.XSourceTB.ReadOnly = true;
this.XSourceTB.Size = new System.Drawing.Size(235, 20);
this.XSourceTB.TabIndex = 197;
this.CoordTT.SetToolTip(this.XSourceTB, "Comma Seperated (e.g. 1, 2, 3, 4)");
//
// XSourceLab
//
this.XSourceLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.XSourceLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.XSourceLab.Location = new System.Drawing.Point(24, 142);
this.XSourceLab.Name = "XSourceLab";
this.XSourceLab.Size = new System.Drawing.Size(139, 20);
this.XSourceLab.TabIndex = 196;
this.XSourceLab.Text = "X-Coordinate(s):";
this.XSourceLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// ColSourceTick
//
this.ColSourceTick.Enabled = false;
this.ColSourceTick.Location = new System.Drawing.Point(169, 75);
this.ColSourceTick.Name = "ColSourceTick";
this.ColSourceTick.Size = new System.Drawing.Size(15, 14);
this.ColSourceTick.TabIndex = 195;
this.ColSourceTick.UseVisualStyleBackColor = true;
this.ColSourceTick.CheckedChanged += new System.EventHandler(this.ColSourceTick_CheckedChanged);
//
// ColSourceLab
//
this.ColSourceLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ColSourceLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.ColSourceLab.Location = new System.Drawing.Point(18, 64);
this.ColSourceLab.Name = "ColSourceLab";
this.ColSourceLab.Size = new System.Drawing.Size(145, 35);
this.ColSourceLab.TabIndex = 194;
this.ColSourceLab.Text = "Source To Span Whole Column";
this.ColSourceLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// YSinkTB
//
this.YSinkTB.Enabled = false;
this.YSinkTB.Location = new System.Drawing.Point(582, 207);
this.YSinkTB.Name = "YSinkTB";
this.YSinkTB.ReadOnly = true;
this.YSinkTB.Size = new System.Drawing.Size(235, 20);
this.YSinkTB.TabIndex = 193;
this.CoordTT.SetToolTip(this.YSinkTB, "Comma Seperated (e.g. 1, 2, 3, 4)");
//
// YSinkLab
//
this.YSinkLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.YSinkLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.YSinkLab.Location = new System.Drawing.Point(460, 206);
this.YSinkLab.Name = "YSinkLab";
this.YSinkLab.Size = new System.Drawing.Size(116, 20);
this.YSinkLab.TabIndex = 192;
this.YSinkLab.Text = "Y-Coordinate(s):";
this.YSinkLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// XSinkTB
//
this.XSinkTB.Enabled = false;
this.XSinkTB.Location = new System.Drawing.Point(582, 177);
this.XSinkTB.Name = "XSinkTB";
this.XSinkTB.ReadOnly = true;
this.XSinkTB.Size = new System.Drawing.Size(235, 20);
this.XSinkTB.TabIndex = 191;
this.CoordTT.SetToolTip(this.XSinkTB, "Comma Seperated (e.g. 1, 2, 3, 4)");
//
// XSinkLab
//
this.XSinkLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.XSinkLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.XSinkLab.Location = new System.Drawing.Point(444, 176);
this.XSinkLab.Name = "XSinkLab";
this.XSinkLab.Size = new System.Drawing.Size(132, 20);
this.XSinkLab.TabIndex = 190;
this.XSinkLab.Text = "X-Coordinate(s):";
this.XSinkLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// ColSinkTick
//
this.ColSinkTick.Enabled = false;
this.ColSinkTick.Location = new System.Drawing.Point(582, 75);
this.ColSinkTick.Name = "ColSinkTick";
this.ColSinkTick.Size = new System.Drawing.Size(15, 14);
this.ColSinkTick.TabIndex = 189;
this.ColSinkTick.UseVisualStyleBackColor = true;
this.ColSinkTick.CheckedChanged += new System.EventHandler(this.ColSinkTick_CheckedChanged);
//
// ColSinkLab
//
this.ColSinkLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ColSinkLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.ColSinkLab.Location = new System.Drawing.Point(434, 64);
this.ColSinkLab.Name = "ColSinkLab";
this.ColSinkLab.Size = new System.Drawing.Size(142, 35);
this.ColSinkLab.TabIndex = 188;
this.ColSinkLab.Text = "Sink To Span Whole Column";
this.ColSinkLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// SinkTick
//
this.SinkTick.Location = new System.Drawing.Point(582, 40);
this.SinkTick.Name = "SinkTick";
this.SinkTick.Size = new System.Drawing.Size(15, 14);
this.SinkTick.TabIndex = 187;
this.SinkTick.UseVisualStyleBackColor = true;
this.SinkTick.CheckedChanged += new System.EventHandler(this.SinkTick_CheckedChanged);
//
// SinkTickLab
//
this.SinkTickLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.SinkTickLab.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.SinkTickLab.Location = new System.Drawing.Point(437, 36);
this.SinkTickLab.Name = "SinkTickLab";
this.SinkTickLab.Size = new System.Drawing.Size(139, 20);
this.SinkTickLab.TabIndex = 186;
this.SinkTickLab.Text = "Include Sinks";
this.SinkTickLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// SourceTick
//
this.SourceTick.Location = new System.Drawing.Point(169, 40);
this.SourceTick.Name = "SourceTick";
this.SourceTick.Size = new System.Drawing.Size(15, 14);
this.SourceTick.TabIndex = 185;
this.SourceTick.UseVisualStyleBackColor = true;
this.SourceTick.CheckedChanged += new System.EventHandler(this.SourceTick_CheckedChanged);
//
// SourceTickLab
//
this.SourceTickLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.SourceTickLab.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.SourceTickLab.Location = new System.Drawing.Point(10, 36);
this.SourceTickLab.Name = "SourceTickLab";
this.SourceTickLab.Size = new System.Drawing.Size(153, 20);
this.SourceTickLab.TabIndex = 184;
this.SourceTickLab.Text = "Include Sources";
this.SourceTickLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// NumSinkTB
//
this.NumSinkTB.Enabled = false;
this.NumSinkTB.Location = new System.Drawing.Point(582, 107);
this.NumSinkTB.Name = "NumSinkTB";
this.NumSinkTB.ReadOnly = true;
this.NumSinkTB.Size = new System.Drawing.Size(120, 20);
this.NumSinkTB.TabIndex = 183;
//
// NumSinkLab
//
this.NumSinkLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.NumSinkLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.NumSinkLab.Location = new System.Drawing.Point(441, 106);
this.NumSinkLab.Name = "NumSinkLab";
this.NumSinkLab.Size = new System.Drawing.Size(135, 20);
this.NumSinkLab.TabIndex = 182;
this.NumSinkLab.Text = "Number of Sinks:";
this.NumSinkLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// SinksTab
//
this.SinksTab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))));
this.SinksTab.Location = new System.Drawing.Point(433, 4);
this.SinksTab.Name = "SinksTab";
this.SinksTab.Size = new System.Drawing.Size(406, 32);
this.SinksTab.TabIndex = 180;
this.SinksTab.Text = "Sinks";
this.SinksTab.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// SourcesTab
//
this.SourcesTab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))));
this.SourcesTab.Location = new System.Drawing.Point(7, 4);
this.SourcesTab.Name = "SourcesTab";
this.SourcesTab.Size = new System.Drawing.Size(405, 32);
this.SourcesTab.TabIndex = 179;
this.SourcesTab.Text = "Sources";
this.SourcesTab.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// NumSourceTB
//
this.NumSourceTB.Enabled = false;
this.NumSourceTB.Location = new System.Drawing.Point(169, 107);
this.NumSourceTB.Name = "NumSourceTB";
this.NumSourceTB.ReadOnly = true;
this.NumSourceTB.Size = new System.Drawing.Size(120, 20);
this.NumSourceTB.TabIndex = 163;
//
// NumSourceLab
//
this.NumSourceLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.NumSourceLab.ForeColor = System.Drawing.SystemColors.GrayText;
this.NumSourceLab.Location = new System.Drawing.Point(21, 106);
this.NumSourceLab.Name = "NumSourceLab";
this.NumSourceLab.Size = new System.Drawing.Size(142, 20);
this.NumSourceLab.TabIndex = 162;
this.NumSourceLab.Text = "Number of Sources:";
this.NumSourceLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// shapeContainer4
//
this.shapeContainer4.Location = new System.Drawing.Point(3, 3);
this.shapeContainer4.Margin = new System.Windows.Forms.Padding(0);
this.shapeContainer4.Name = "shapeContainer4";
this.shapeContainer4.Shapes.AddRange(new Microsoft.VisualBasic.PowerPacks.Shape[] {
this.lineShape5});
this.shapeContainer4.Size = new System.Drawing.Size(1021, 249);
this.shapeContainer4.TabIndex = 181;
this.shapeContainer4.TabStop = false;
//
// lineShape5
//
this.lineShape5.BorderColor = System.Drawing.SystemColors.ControlDarkDark;
this.lineShape5.Name = "lineShape5";
this.lineShape5.X1 = 428;
this.lineShape5.X2 = 428;
this.lineShape5.Y1 = 11;
this.lineShape5.Y2 = 210;
//
// Outputs
//
this.Outputs.BackColor = System.Drawing.SystemColors.Control;
this.Outputs.Controls.Add(this.RunLengthTB);
this.Outputs.Controls.Add(this.RunLengthLab);
this.Outputs.Controls.Add(this.OutputNameTB);
this.Outputs.Controls.Add(this.OutputNameLab);
this.Outputs.Controls.Add(this.SaveFreqTB);
this.Outputs.Controls.Add(this.SaveFreqLab);
this.Outputs.Location = new System.Drawing.Point(4, 22);
this.Outputs.Name = "Outputs";
this.Outputs.Size = new System.Drawing.Size(1027, 255);
this.Outputs.TabIndex = 14;
this.Outputs.Text = "Outputs";
//
// RunLengthTB
//
this.RunLengthTB.Location = new System.Drawing.Point(163, 112);
this.RunLengthTB.Name = "RunLengthTB";
this.RunLengthTB.Size = new System.Drawing.Size(120, 20);
this.RunLengthTB.TabIndex = 184;
this.RunLengthTB.Text = "1095000";
//
// RunLengthLab
//
this.RunLengthLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.RunLengthLab.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.RunLengthLab.Location = new System.Drawing.Point(33, 111);
this.RunLengthLab.Name = "RunLengthLab";
this.RunLengthLab.Size = new System.Drawing.Size(124, 20);
this.RunLengthLab.TabIndex = 183;
this.RunLengthLab.Text = "Run Length (Days):";
this.RunLengthLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// OutputNameTB
//
this.OutputNameTB.Location = new System.Drawing.Point(163, 39);
this.OutputNameTB.Name = "OutputNameTB";
this.OutputNameTB.Size = new System.Drawing.Size(120, 20);
this.OutputNameTB.TabIndex = 182;
this.OutputNameTB.Text = "CEM";
//
// OutputNameLab
//
this.OutputNameLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.OutputNameLab.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.OutputNameLab.Location = new System.Drawing.Point(53, 38);
this.OutputNameLab.Name = "OutputNameLab";
this.OutputNameLab.Size = new System.Drawing.Size(104, 20);
this.OutputNameLab.TabIndex = 181;
this.OutputNameLab.Text = "File Name:";
this.OutputNameLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// SaveFreqTB
//
this.SaveFreqTB.Location = new System.Drawing.Point(163, 76);
this.SaveFreqTB.Name = "SaveFreqTB";
this.SaveFreqTB.Size = new System.Drawing.Size(120, 20);
this.SaveFreqTB.TabIndex = 180;
this.SaveFreqTB.Text = "3650";
//
// SaveFreqLab
//
this.SaveFreqLab.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.SaveFreqLab.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
this.SaveFreqLab.Location = new System.Drawing.Point(53, 75);
this.SaveFreqLab.Name = "SaveFreqLab";
this.SaveFreqLab.Size = new System.Drawing.Size(104, 20);
this.SaveFreqLab.TabIndex = 179;
this.SaveFreqLab.Text = "Save Frequency:";
this.SaveFreqLab.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// CoordTT
//
this.CoordTT.AutoPopDelay = 5000;
this.CoordTT.BackColor = System.Drawing.SystemColors.InactiveBorder;
this.CoordTT.InitialDelay = 500;
this.CoordTT.ReshowDelay = 100;
this.CoordTT.ShowAlways = true;
//
// SeeTabsButton
//
this.SeeTabsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.SeeTabsButton.Location = new System.Drawing.Point(447, 291);
this.SeeTabsButton.Name = "SeeTabsButton";
this.SeeTabsButton.Size = new System.Drawing.Size(86, 24);
this.SeeTabsButton.TabIndex = 178;
this.SeeTabsButton.Text = "See Tabs";
this.SeeTabsButton.Visible = false;
this.SeeTabsButton.Click += new System.EventHandler(this.SeeTabsButton_Click);
//
// zoomPanImageBox1
//
this.zoomPanImageBox1.AutoScroll = true;
this.zoomPanImageBox1.Image = null;
this.zoomPanImageBox1.Location = new System.Drawing.Point(8, 34);
this.zoomPanImageBox1.Name = "zoomPanImageBox1";
this.zoomPanImageBox1.Size = new System.Drawing.Size(855, 212);
this.zoomPanImageBox1.TabIndex = 148;
this.zoomPanImageBox1.Visible = false;
this.zoomPanImageBox1.Load += new System.EventHandler(this.zoomPanImageBox1_Load);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.AutoScroll = true;
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(1088, 362);
this.Controls.Add(this.SeeTabsButton);
this.Controls.Add(this.pauseButton);
this.Controls.Add(this.quitSaveButton);
this.Controls.Add(this.startButton);
this.Controls.Add(this.loadDataButton);
this.Controls.Add(this.resumeButton);
this.Controls.Add(this.MainWindowTabs);
this.Controls.Add(this.statusBar1);
this.Controls.Add(this.zoomPanImageBox1);
this.Controls.Add(this.UpdateGraphPanel);
this.Controls.Add(this.ZoomSlider);
this.Controls.Add(this.ViewTabsCheck);
this.Controls.Add(this.Graphic_ContrastSlider);
this.Menu = this.mainMenu1;
this.MinimumSize = new System.Drawing.Size(920, 400);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Coastline Evolution Model (v.6)";
this.Load += new System.EventHandler(this.Form1_Load);
this.Shown += new System.EventHandler(this.Form1_Shown);
this.Resize += new System.EventHandler(this.Form1_Resize);
((System.ComponentModel.ISupportInitialize)(this.InfoStatusPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.IterationStatusPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.TimeStatusPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.QwStatusPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.QsStatusPanel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.waveAnglePanel)).EndInit();
this.UpdateGraphPanel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.Graphic_ContrastSlider.ResumeLayout(false);
this.Graphic_ContrastSlider.PerformLayout();
this.ZoomSlider.ResumeLayout(false);
this.ZoomSlider.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit();
this.DescriptionTab.ResumeLayout(false);
this.DescriptionTab.PerformLayout();
this.WaveTab.ResumeLayout(false);
this.WaveTab.PerformLayout();
this.DEMTab.ResumeLayout(false);
this.DEMTab.PerformLayout();
this.MainWindowTabs.ResumeLayout(false);
this.TideTab.ResumeLayout(false);
this.TideTab.PerformLayout();
this.ErosionTab.ResumeLayout(false);
this.ErosionTab.PerformLayout();
this.SourceSinkTab.ResumeLayout(false);
this.SourceSinkTab.PerformLayout();
this.Outputs.ResumeLayout(false);
this.Outputs.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
// Run when the 'Load' button is clicked
private void loadDataButton_Click(object sender, System.EventArgs e)
{
// Check for errors
List errors = new List();
errors.Add("Some data is missing or invalid, please check:" + Environment.NewLine + Environment.NewLine);
if ((string.IsNullOrWhiteSpace(this.ColumnTB.Text)) || (string.IsNullOrWhiteSpace(this.RowsTB.Text)))
{
errors.Add(" - DEM" + Environment.NewLine);
}
else if (CompDEMTick.Checked == true && ((Convert.ToDouble(ColumnTB.Text) < 50) || (Convert.ToDouble(RowsTB.Text) < 50)))
{
errors.Add(" - Minimum DEM size = 50 x 50" + Environment.NewLine);
}
if ((ManWavTick.Checked == true) && ((string.IsNullOrWhiteSpace(this.WAngleTB.Text)) || (string.IsNullOrWhiteSpace(this.WPeriodTB.Text)) || (string.IsNullOrWhiteSpace(this.WHeightTB.Text))))
{
errors.Add(" - Wave Data" + Environment.NewLine);
}
else if ((WaveFileTick.Checked == true) && ((string.IsNullOrWhiteSpace(this.WALoadTB.Text)) || (string.IsNullOrWhiteSpace(this.WPLoadTB.Text)) || (string.IsNullOrWhiteSpace(this.WHLoadTB.Text))))
{
errors.Add(" - Wave Data" + Environment.NewLine);
}
else if (ManWavTick.Checked == false && WaveFileTick.Checked == false && UA_WaveTick.Checked == false)
{
errors.Add(" - Wave Data" + Environment.NewLine);
}
if (DoTidesTick.Checked == true && (string.IsNullOrWhiteSpace(this.LowTideTB.Text)))
{
errors.Add(" - Tide Data" + Environment.NewLine);
}
if ((string.IsNullOrWhiteSpace(this.ErosRateTB.Text)) || (string.IsNullOrWhiteSpace(this.PercentFastTB.Text)) || (string.IsNullOrWhiteSpace(this.PercentSlowTB.Text)) || (string.IsNullOrWhiteSpace(this.RockWeatherTB.Text)) || (string.IsNullOrWhiteSpace(this.SlowWeatherTB.Text)) || (string.IsNullOrWhiteSpace(this.FastWeatherTB.Text)))
{
errors.Add(" - Erosion and Weathering Rates" + Environment.NewLine);
}
if (SourceTick.Checked == true)
{
if ((ColSourceTick.Checked == true) && ((string.IsNullOrWhiteSpace(this.NumSourceTB.Text)) || (string.IsNullOrWhiteSpace(this.XSourceTB.Text))))
{
errors.Add(" - Sediment Source(s)" + Environment.NewLine);
}
else if ((ColSourceTick.Checked == false) && ((string.IsNullOrWhiteSpace(this.NumSourceTB.Text)) || (string.IsNullOrWhiteSpace(this.XSourceTB.Text)) || (string.IsNullOrWhiteSpace(this.YSourceTB.Text))))
{
errors.Add(" - Sediment Source(s)" + Environment.NewLine);
}
}
if (SinkTick.Checked == true)
{
if ((ColSinkTick.Checked == true) && ((string.IsNullOrWhiteSpace(this.NumSinkTB.Text)) || (string.IsNullOrWhiteSpace(this.XSinkTB.Text))))
{
errors.Add(" - Sediment Sink(s)" + Environment.NewLine);
}
else if ((ColSinkTick.Checked == false) && ((string.IsNullOrWhiteSpace(this.NumSinkTB.Text)) || (string.IsNullOrWhiteSpace(this.XSinkTB.Text)) || (string.IsNullOrWhiteSpace(this.YSinkTB.Text))))
{
errors.Add(" - Sediment Sink(s)" + Environment.NewLine);
}
}
if ((string.IsNullOrWhiteSpace(this.SaveFreqTB.Text)) || (string.IsNullOrWhiteSpace(this.OutputNameTB.Text)) || (string.IsNullOrWhiteSpace(this.RunLengthTB.Text)))
{
errors.Add(" - Outputs" + Environment.NewLine);
}
else if (string.IsNullOrWhiteSpace(this.RunLengthTB.Text))
{
errors.Add(" - Outputs" + Environment.NewLine);
}
else if (Convert.ToDouble(this.RunLengthTB.Text) % 1 != 0)
{
errors.Add(" - Run Length must be a whole number (Days)" + Environment.NewLine);
}
if(errors.Count > 1)
{
DialogResult Result = MessageBox.Show((string.Join(" ", errors.ToArray())), "Missing Data", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
if (Result == DialogResult.OK)
{
return;
}
}
// Initialise Arrays, Variables and Graphics
initialise();
load_DEM();
// Which items in the designer will be visible once the 'Load' button is clicked
MainWindowTabs.Visible = false;
ViewTabsCheck.Checked = false;
zoomPanImageBox1.Visible = true;
UpdateGraphPanel.Visible = true;
loadDataButton.Enabled = false;
Graphic_ContrastSlider.Visible = true;
ZoomSlider.Visible = true;
startButton.Visible = true;
// Batch
if (autorestart == 1 && Restart_count > 1)
{
startButton.PerformClick();
}
}
private void initialise()
{
this.InfoStatusPanel.Text = "Initialising...";
DEMFilePath = Directory.GetCurrentDirectory() + "/INPUT_FILES/" + DEMTextBox.Text;
//Setup
//StartFromFile?
if (DEMTick.Checked == true)
{
StartFromFile = 'y';
}
else if (DEMTick.Checked == false)
{
StartFromFile = 'n';
}
//InitCType - 0: normal (columns/blocks), 1: wiggly, 2: one block
if (NormTick.Checked == true)
{
InitCType = 0;
}
else if (WigglyTick.Checked == true)
{
InitCType = 1;
}
else if (BlockTick.Checked == true)
{
InitCType = 2;
}
else if (PertTick.Checked == true)
{
InitCType = 0;
InitialPert = 1;
}
else if (InitPertTick.Checked == true)
{
InitCType = 0;
InitialPert = 3;
}
else
{
InitCType = -999;
InitialPert = 0;
}
//xmax ymax
if (StartFromFile == 'y')
{
int z;
string[] lineArray2;
int sp;
inputheader = new string[6];
//read headers (lines 0 - 5)
StreamReader sr = File.OpenText(DEMFilePath);
for (z = 1; z <= 6; z++)
{
inputheader[z - 1] = sr.ReadLine();
}
sr.Close();
// get xmax, ymax and DX from input headers
lineArray2 = inputheader[0].Split(new char[] { ' ' }); // Number of Columns
sp = 1;
while (lineArray2[sp] == "") sp++;
xmax = int.Parse(lineArray2[sp]);
lineArray2 = inputheader[1].Split(new char[] { ' ' }); // Number of Rows
sp = 1;
while (lineArray2[sp] == "") sp++;
ymax = ((int.Parse(lineArray2[sp])));
lineArray2 = inputheader[2].Split(new char[] { ' ' }); // xllcorner
sp = 1;
while (lineArray2[sp] == "") sp++;
xll = double.Parse(lineArray2[sp]);
lineArray2 = inputheader[3].Split(new char[] { ' ' }); // yllcorner
sp = 1;
while (lineArray2[sp] == "") sp++;
yll = double.Parse(lineArray2[sp]);
//lineArray2 = inputheader[4].Split(new char[] { ' ' }); // cell size
//sp = 1;
//while (lineArray2[sp] == "") sp++;
//DX = int.Parse(lineArray2[sp]);
//root = (Math.Sqrt(Math.Pow(DX, 2) + Math.Pow(DX, 2)));
//fiveroot = (Math.Sqrt(Math.Pow(DX, 2) + Math.Pow(DX, 2)));
//Trying to test why changing cell width makes a big difference in NEW model
DX = CellWidth;
root = (Math.Sqrt(Math.Pow(DX, 2) + Math.Pow(DX, 2)));
fiveroot = (Math.Sqrt(Math.Pow(DX, 2) + Math.Pow(DX, 2)));
}
else if (StartFromFile == 'n')
{
xmax = Convert.ToInt32(this.ColumnTB.Text);
ymax = Convert.ToInt32(this.RowsTB.Text);
xll = 0;
yll = 0;
DX = CellWidth;
root = (Math.Sqrt(Math.Pow(DX, 2) + Math.Pow(DX, 2)));
fiveroot = (Math.Sqrt(Math.Pow(DX, 2) + Math.Pow(DX, 2)));
}
// Create a drawing surface with the same dimensions DEM
m_objDrawingSurface = new Bitmap((xmax*2) * graphics_scale,
ymax * graphics_scale, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
save_interval2 = 1000;
save_time2 = save_interval2;
root = (Math.Sqrt(Math.Pow(DX, 2) + Math.Pow(DX, 2)));
fiveroot = (Math.Sqrt(Math.Pow(DX, 2) + Math.Pow(DX, 2)));
init_cycle = cycle;
tx = output_file_save_interval;
// Dimensions - periodic boundary/display
xDisplayStart = xmax / 2;
xDisplayEnd = (3 * xmax) / 2;
pbEnd = xmax*2;
// Tides
Highness = 1 - Highness; //Compensate for highness error
if (DoTidesTick.Checked == true)
{
DoTides = 1;
WaterLevel = Convert.ToDouble(this.LowTideTB.Text); // What height is the tide?
HighWaterHeight = Convert.ToDouble(this.HighTideTB.Text); // Level of HighTide
int Rate = 4380; //Convert.ToInt32(Math.Floor(HighWaterHeight) * 2); // How many iterations to get from low to high water?
double WLIncrement = HighWaterHeight / Rate; // How much does the water need to raise on each iteration?
WLArray = new double[(Rate * 2) + 1];
double WLValue = WaterLevel;
for (int x = 0; x <= Rate; x++)
{
WLArray[x] = WLValue;
WLValue += WLIncrement;
}
WLValue -= WLIncrement;
for (int x = Rate + 1; x < WLArray.Length; x++)
{
WLValue -= WLIncrement;
WLArray[x] = WLValue;
if (x == WLArray.Length - 1)
{
WLArray[x] = WaterLevel;
}
}
}
else if (DoTidesTick.Checked == false)
{
DoTides = 0;
}
if (DoSLRTick.Checked == true)
{
DoSLR = 1;
SLR = Convert.ToDouble(this.SLR_TB.Text);
SLRrate = (Convert.ToInt32(this.RateSLR_TB.Text) * 365);
if (StepSLR_Tick.Checked == false)
{
double SLRIncrement = SLR / SLRrate;
SLRArray = new double[SLRrate + 1];
double SLRValue = 0;
for (int x = 0; x <= SLRrate; x++)
{
SLRArray[x] = SLRValue;
SLRValue += SLRIncrement;
}
}
else if (StepSLR_Tick.Checked == true)
{
double SLRIncrement = SLR;
SLRArray = new double[Convert.ToInt32(this.RunLengthTB.Text) + 1];
double SLRValue = 0;
for (int x = 0; x <= Convert.ToInt32(this.RunLengthTB.Text); x++)
{
if (x % SLRrate == 0 && x > 0)
{
SLRValue += SLRIncrement;
}
SLRArray[x] = SLRValue;
}
}
}
else
{
DoSLR = 0;
}
// Waves - NEED TO LOOK AT WAVE = 0?
if (autorestart == 0)
{
if (ManWavTick.Checked == true)
{
WaveIn = 3;
}
else if (WaveFileTick.Checked == true && BinnedTick.Checked == false)
{
WaveIn = 2;
}
else if (BinnedTick.Checked == true)
{
WaveIn = 1;
ReadWaveIn(); // Initialise WaveMax and WaveProb
}
else if (UA_WaveTick.Checked == true)
{
WaveIn = 0;
Asym = Convert.ToDouble(this.AsymTB.Text); // fractional portion of waves coming from positive (left) direction
Highness = Convert.ToDouble(this.HighTB.Text); // .5 = even dist, > .5 high angle domination.
Highness = 1 - Highness;
}
}
// Erosion
NoWeathering = Convert.ToDouble(this.RockWeatherTB.Text); // weathering of rock only occurs below this amt of sed cover (vert equiv in meters) LMV */
SlowWeatherCoeff = Convert.ToDouble(this.SlowWeatherTB.Text); // Weathering rate of slow rock e.g. 0.5 = slow weathering, 1/2 as fast LMV
FastWeatherCoeff = Convert.ToDouble(this.FastWeatherTB.Text); // Weathering rate of fast rock e.g. 2 = fast weathering, 2 times faster than normal LMV
PercentFineFast = Convert.ToDouble(this.PercentFastTB.Text); // Percent of fast weathering rock lost because it is too fine to stay in nearshore LMV
PercentFineSlow = Convert.ToDouble(this.PercentSlowTB.Text); // Percent of slow weathering rock lost because it is too fine to stay in nearshore LMV
ErosionRatePerYear = Convert.ToDouble(this.ErosRateTB.Text);
ChunkLength = xmax;
// Shadow
ShadowYMax = ymax;
// Sinks
if (SinkTick.Checked == true)
{
// Have Sinks?
HaveSinks = 1; // yes
NumSinks = Convert.ToInt32(this.NumSinkTB.Text); // Number of Sinks
//Sinkiness
if (string.IsNullOrWhiteSpace(this.SinkinessTB.Text))
{
Sinkiness = 0;
}
else
{
Sinkiness = ((Convert.ToDouble(this.SinkinessTB.Text)) / 100); // fractional value determines chance that sediment in the sink is deleted
}
//XYSink
string XSinkInput = XSinkTB.Text;
XSinkInput = XSinkInput.Replace("\r\n", " ");
XSinkInput = XSinkInput.Replace("\t", " ");
XSinkInput = XSinkInput.Replace(",", " ");
XSinkInput = Regex.Replace(XSinkInput, @"\s+", " ");
XSinkInput = XSinkInput.Trim();
string[] XSinkInput_Split = XSinkInput.Split(' ');
SinkX = new int[XSinkInput_Split.Length];
int x;
for (x = 0; x < XSinkInput_Split.Length; x++)
{
SinkX[x] = Convert.ToInt32(XSinkInput_Split[x]);
}
// Column Sink?
if (ColSinkTick.Checked == true)
{
ColumnSinks = 1; // Sink spans whole column
}
else if (ColSinkTick.Checked == false)
{
ColumnSinks = 0;
string YSinkInput = YSinkTB.Text;
YSinkInput = YSinkInput.Replace("\r\n", " ");
YSinkInput = YSinkInput.Replace("\t", " ");
YSinkInput = Regex.Replace(YSinkInput, @"\s+", " ");
YSinkInput = YSinkInput.Replace(",", " ");
YSinkInput = YSinkInput.Trim();
string[] YSinkInput_Split = YSinkInput.Split(' ');
SinkY = new int[YSinkInput_Split.Length];
int y;
for (y = 0; y < YSinkInput_Split.Length; y++)
{
SinkY[y] = Convert.ToInt32(YSinkInput_Split[y]);
}
}
}
else if (SinkTick.Checked == false)
{
HaveSinks = 0; // 0 = No
NumSinks = 0; // N/A
}
//Sources
if (SourceTick.Checked == true)
{
// Have Source?
NumSources = Convert.ToInt32(this.NumSourceTB.Text); // Number of Sources
//XYSink
string XSourceInput = XSourceTB.Text;
XSourceInput = XSourceInput.Replace("\r\n", " ");
XSourceInput = XSourceInput.Replace("\t", " ");
XSourceInput = XSourceInput.Replace(",", " ");
XSourceInput = Regex.Replace(XSourceInput, @"\s+", " ");
XSourceInput = XSourceInput.Trim();
string[] XSourceInput_Split = XSourceInput.Split(' ');
SourceX = new int[XSourceInput_Split.Length];
int x;
for (x = 0; x < XSourceInput_Split.Length; x++)
{
SourceX[x] = Convert.ToInt32(XSourceInput_Split[x]);
}
// Column Source?
if (ColSourceTick.Checked == true)
{
ColumnSources = 1; // Source spans whole column
}
else if (ColSourceTick.Checked == false)
{
ColumnSources = 0;
string YSourceInput = YSourceTB.Text;
YSourceInput = YSourceInput.Replace("\r\n", " ");
YSourceInput = YSourceInput.Replace("\t", " ");
YSourceInput = Regex.Replace(YSourceInput, @"\s+", " ");
YSourceInput = YSourceInput.Replace(",", " ");
YSourceInput = YSourceInput.Trim();
string[] YSourceInput_Split = YSourceInput.Split(' ');
SourceY = new int[YSourceInput_Split.Length];
int y;
for (y = 0; y < YSourceInput_Split.Length; y++)
{
SourceY[y] = Convert.ToInt32(YSourceInput_Split[y]);
}
}
}
else if (SourceTick.Checked == false)
{
NumSources = 0; // N/A
}
// Outputs
SaveFrequency = Convert.ToInt32(this.SaveFreqTB.Text); // Counter interval to save image
SaveSpacing = SaveFrequency; // space between saved files
StopAfter = Convert.ToInt32(this.RunLengthTB.Text);
// Batch
if (autorestart == 1)
{
savefilename = "Run_" + Restart_count;
}
else
{
savefilename = this.OutputNameTB.Text;
}
// General Arrays
AllBeach = new int[pbEnd, ymax]; // Flag indicating of cell is entirely beach
AllRock = new int[pbEnd, ymax]; // Flag indicating if cell is entirely rock LMV
PercentFullSand = new double[pbEnd, ymax]; // Fractional amount of cell full of sediment LMV
PercentFullRock = new double[pbEnd, ymax]; // Fractional amount of a cell full of rock LMV
AboveWater = new int[pbEnd, ymax];
AboveTideOLD = new bool[pbEnd, ymax]; // Flag indicating if a cell is above the tide mark
TypeOfRock = new char[pbEnd, ymax]; // Array to control weathering rates of rock along the beach LMV
Age = new int[pbEnd, ymax]; // Age since cell was deposited
MaxBeachLength = xmax * ymax; //20 * ymax;
CellDepth = new double[pbEnd, ymax];
ShorelineCell = new int[pbEnd, ymax];
Linear_Shoreline = new int[pbEnd, ymax];
// CM - Adding elevation volumes
DepthEffectiveArray = new double[pbEnd, ymax];
//LocalAngle = new double[pbEnd, ymax];
LowestX = new int[pbEnd, ymax];
LowestY = new int[pbEnd, ymax];
SedimentChange = new double[pbEnd, ymax];
VolumeChange = new double[pbEnd, ymax];
Elevation = new double[pbEnd, ymax]; // Elevation of beach
WaterDepth0 = new double[pbEnd, ymax]; // Water depth from DEM (ref: 0m)
DepthShelf = new double[pbEnd, ymax]; // Depth from '0' to Shelf
DomainDepthCS = new double[pbEnd, ymax]; // Depth to domain bottom from continental shelf
DepthShelfMaterial = new double[pbEnd, ymax]; // Depth of material to shelf from 0 level (will sometimes be same as depthShelf)
TElevationCS = new double[pbEnd, ymax]; // Total elevation of material from continental shelf (used to work out volume!)
TElevationDomain = new double[pbEnd, ymax]; // Total elevation of material from bottom of the domain (used to work out above/below water)
Volume = new double[pbEnd, ymax];
OriginalVol = new double[pbEnd, ymax];
PreviousVolume = new double[pbEnd, ymax]; ;
direction = new int[MaxBeachLength]; // 1 = Top 2 = Top right 3 = Right 4 = Bottom Right 5 = Bottom 6 = Bottom left 7 = Left 8 = Top Left
numCells = new int[MaxBeachLength]; // How many cells from the coastline do we extend out for the shoreface slope?
localSFS = new double[MaxBeachLength];
XSt = new int[MaxBeachLength];;
YSt = new int[MaxBeachLength];;
// Computational Arrays (determined for each time step)
X = new int[MaxBeachLength];
Y = new int[MaxBeachLength];
initialX = new int[MaxBeachLength];
initialY = new int[MaxBeachLength];
XBehind = new int[MaxBeachLength];
YBehind = new int[MaxBeachLength];
XRock = new int[MaxBeachLength];
YRock = new int[MaxBeachLength];
XRockBehind = new int[MaxBeachLength];
YRockBehind = new int[MaxBeachLength];
InShadow = new char[MaxBeachLength];
InShadow_domain = new double[pbEnd, ymax];
ShorelineAngle = new double[MaxBeachLength];
SurroundingAngle = new double[MaxBeachLength];
UpWind = new char[MaxBeachLength];
VolumeIn = new double[MaxBeachLength];
VolumeOut = new double[MaxBeachLength];
VolumeAcrossBorder = new double[MaxBeachLength];
ActualVolumeAcross = new double[MaxBeachLength];
DirectionAcrossBorder = new char[MaxBeachLength];
FlowThroughCell = new char[MaxBeachLength];
DistanceToBeach = new double[MaxBeachLength];
MinDistanceToBeach = new double[MaxBeachLength];
ClosestBeach = new int[MaxBeachLength];
AmountWeathered = new double[MaxBeachLength];
//LostMaterial = new double[Convert.ToInt32(StopAfter)];
Angle_1 = new double[MaxBeachLength];
// This needs to be placed better - the above shouldn't run if InitialiseFile = 'y', but not using this atm
if (InitialiseFile == 'y')
{
//ControlFile(); // Read in initialisation data to control model
}
// Save Files
if (SaveLine == 1)
{
SaveLineToFile();
}
if (Metadata == 'y')
{
MetaFile(); // Read in initialisation data to control model
}
}
void load_DEM()
{
// DEM loaded from file
if (StartFromFile == 'y')
{
//int x;
//int i = 0, j = 0, k = 0;
//int y = xDisplayStart - 1;
//string Original_DEM = "INPUT_FILES/CEM_PertShort.dat";
//StreamReader read_originalDEM = new StreamReader(Original_DEM);
//string[] fileTrimmed_Original = new string[xmax * (ymax * 3)];
//string fileContent_DEMOriginal = File.ReadAllText(Original_DEM);
//fileContent_DEMOriginal = fileContent_DEMOriginal.Replace("\r\n", " ");
//fileContent_DEMOriginal = Regex.Replace(fileContent_DEMOriginal, @"\s+", " ");
//string[] fileSplit_DEMOriginal = fileContent_DEMOriginal.Split(' ');
//if (!File.Exists(Original_DEM))
//{
// return;
//}
//// Remove headers from array
//for (i = 12; i < fileSplit_DEMOriginal.Length - 1; i++)
//{
// fileTrimmed_Original[j] = fileSplit_DEMOriginal[i];
// j++;
//}
//k = 0;
//// Create TypeOfRock Array
//for (y = ymax - 1; y >= 0; y--)
//{
// for (x = xDisplayStart; x < xDisplayEnd; x++)
// {
// TypeOfRock[x, y] = Convert.ToChar(fileTrimmed_Original[k]);
// k++;
// }
//}
//// Create PercentFullRock Array
//for (y = ymax - 1; y >= 0; y--)
//{
// for (x = xDisplayStart; x < xDisplayEnd; x++)
// {
// PercentFullRock[x, y] = Convert.ToDouble(fileTrimmed_Original[k]);
// if (PercentFullRock[x, y] >= 1.0)
// {
// AllRock[x, y] = 1;
// }
// else
// {
// AllRock[x, y] = 0;
// }
// k++;
// }
//}
//// Create PercentFullSand Array
//for (y = ymax - 1; y >= 0; y--)
//{
// for (x = xDisplayStart; x < xDisplayEnd; x++)
// {
// PercentFullSand[x, y] = Convert.ToDouble(fileTrimmed_Original[k]);
// if ((PercentFullSand[x, y] + PercentFullRock[x, y]) >= MaxFillCell)
// {
// AllBeach[x, y] = 1;
// }
// else
// {
// AllBeach[x, y] = 0;
// }
// k++;
// }
//}
//read_originalDEM.Close();
}
// Computer Generated DEM
//CM - need to sort out elevation if computer-generated file is created!
else if (StartFromFile == 'n')
{
InitConds();
//if (InitialPert == 1)
//{
// InitPert();
//}
}
// Depth to ContinentalShelf (DepthShelf)
int r, s;
for (s = ymax - 1; s >= 0; s--)
{
for (r = xDisplayStart; r < xDisplayEnd; r++)
{
Depth = InitialDepth + ((s - InitBeach) * CellWidth * ShelfSlope);
Distance = Depth / (ShorefaceSlope - ShelfSlope /** Math.Cos(ShorelineAngle[i])*/);
Yintercept = s + Distance /** Math.Cos(ShorelineAngle[i])*/ / CellWidth;
DepthShelf[r, s] = Depth;
if (DepthShelf[r, s] < DepthShoreface)
{
DepthShelf[r, s] = DepthShoreface;
}
}
}
// Max domain depth (reference point)
maxDomainDepth = DepthShelf[xDisplayEnd - 1, ymax - 1];
// Create Elevaition Array
string DEMFilePath = "INPUT_FILES/Paper_coast_4.txt";
string fileContent_DEM = File.ReadAllText(DEMFilePath);
fileContent_DEM = fileContent_DEM.Replace("\r\n", " ");
fileContent_DEM = Regex.Replace(fileContent_DEM, @"\s+", " ");
string[] fileSplit_DEM = fileContent_DEM.Split(' ');
// Elevation (positive) and water depth (negative) array
int m = 12;
int a,b;
for (b = ymax - 1; b >= 0; b--)
{
for (a = xDisplayStart; a < xDisplayEnd; a++)
{
if (Convert.ToDouble(fileSplit_DEM[m]) > 0)
{
Elevation[a, b] = Convert.ToDouble(fileSplit_DEM[m]);
WaterDepth0[a, b] = 0;
}
else
{
Elevation[a, b] = 0;
WaterDepth0[a, b] = Convert.ToDouble(fileSplit_DEM[m]) * -1;
if (WaterDepth0[a, b] > DepthShelf[a, b])
{
WaterDepth0[a, b] = DepthShelf[a, b];
}
}
m++;
}
}
// Calculate Domain Depth from continental shelf depth
for (s = ymax - 1; s >= 0; s--)
{
for (r = xDisplayStart; r < xDisplayEnd; r++)
{
DomainDepthCS[r, s] = maxDomainDepth - DepthShelf[r, s];
}
}
// Calculate amount of material in cells, BELOW 0m
//StreamWriter DepthShelfMaterial_FILE = new StreamWriter("OUTPUT_FILES/DepthShelfMaterial_File.dat");
//StreamWriter TElevationCS_FILE = new StreamWriter("OUTPUT_FILES/TElevationCS_File.dat");
//StreamWriter Volume_FILE = new StreamWriter("OUTPUT_FILES/Volume_File.dat");
//StreamWriter AboveWater_FILE = new StreamWriter("OUTPUT_FILES/AboveWater_File.dat");
//DepthShelfMaterial_FILE.Write("ncols 150" + Environment.NewLine + "nrows 100" + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
//TElevationCS_FILE.Write("ncols 150" + Environment.NewLine + "nrows 100" + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
//Volume_FILE.Write("ncols 150" + Environment.NewLine + "nrows 100" + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
//AboveWater_FILE.Write("ncols 150" + Environment.NewLine + "nrows 100" + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
// Batch
StreamWriter TElevationDomain_FILE;
if (autorestart == 1)
{
TElevationDomain_FILE = new StreamWriter("OUTPUT_FILES/Run_" + Restart_count + "/TElevationDomain_File_" + Restart_count + "_" + counter + ".dat");
wavesavename = "OUTPUT_FILES/Run_" + Restart_count + "/wavedata.out";
}
else
{
TElevationDomain_FILE = new StreamWriter("OUTPUT_FILES/TElevationDomain_File_" + counter + ".dat");
wavesavename = "OUTPUT_FILES/wavedata.out";
}
TElevationDomain_FILE.Write("ncols 150" + Environment.NewLine + "nrows 100" + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
for (s = ymax - 1; s >= 0; s--)
{
for (r = xDisplayStart; r < xDisplayEnd; r++)
{
DepthShelfMaterial[r, s] = DepthShelf[r, s] - WaterDepth0[r, s]; // ONLY FOR CELLS ABOVE THE WATER
TElevationCS[r, s] = DepthShelfMaterial[r, s] + Elevation[r, s];
TElevationDomain[r, s] = TElevationCS[r, s] + DomainDepthCS[r, s];
Volume[r, s] = TElevationCS[r, s] * CellWidth * CellWidth;
if (TElevationDomain[r,s] >= WaterLevel + maxDomainDepth + WDThreshold)
{
AboveWater[r, s] = 1;
}
else
{
AboveWater[r,s] = 0;
}
TElevationDomain_FILE.Write(TElevationDomain[r, s] + " ");
}
TElevationDomain_FILE.Write(Environment.NewLine);
}
TElevationDomain_FILE.Close();
// Finish off creating the arrays with PBCopy
PeriodicBoundaryCopy();
for (int wy = ymax - 1; wy >= 0; wy--)
{
for (int ex = 0; ex < pbEnd; ex++)
{
TotalSediment += Volume[ex, wy];
}
}
this.InfoStatusPanel.Text = "Loaded: type = " + input_type_flag.ToString();
}
// Run when 'Start' button is clicked
private void start_button_Click(object sender, System.EventArgs e)
{
quitSaveButton.Visible = false;
loadDataButton.Visible = false;
SeeTabsButton.Visible = false;
}
private void main_loop(object sender, System.EventArgs e)
{
int n;
double tempflow=baseflow;
double ince=cycle+60;
gameClock = new Timer();
pauseButton.Visible = true;
resumeButton.Visible = true;
quitSaveButton.Visible = true;
SeeTabsButton.Visible = true;
cycle = 0;
time_1 = 1;
time_factor = 60;
time_factor = 1;
save_time = cycle;
time_1 = cycle;
// Creates the system drawing graphics
mygraphics = this.CreateGraphics();
this.InfoStatusPanel.Text="Starting main loop";
this.InfoStatusPanel.Text="Running";
// Here we go into the main loop,
// not sure why its within a game clock thing, but I copied this bit of code to get
// the event handler to work - and it seems OK so why change it.
// so the main loop is really in erodedepo()
for(n=1;n<=1;n++)
{
gameClock.Interval = 1;
gameClock.Tick += new EventHandler(CEMmain);
gameClock.Start();
}
}
//protected override void OnFormClosing(FormClosingEventArgs e)
//{
// pauseButton_Click(pauseButton, EventArgs.Empty);
// endTime = DateTime.Now.TimeOfDay;
// speed = (endTime - startTime);
// DialogResult Result = MessageBox.Show(("Program at " + (counter - 1) + " days \nDo you want to exit? \n\nSpeed: " + speed.Hours + ":" + speed.Minutes + ":" + speed.Seconds + "(hh:mm:ss)"), " ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
// if (Result == DialogResult.Yes)
// {
// //StreamWriter EndVol = new StreamWriter("OUTPUT_FILES/MorphChange/EndVol" + WaveFileTB.Text + ".out");
// //EndVol.Write("ncols " + ColumnTB.Text + Environment.NewLine + "nrows " + RowsTB.Text + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
// //for (int yyyy = ymax - 1; yyyy >= 0; yyyy--)
// //{
// // for (int xxxx = 0; xxxx < pbEnd; xxxx++)
// // {
// // EndVol.Write(Volume[xxxx, yyyy] + " ");
// // TotalVolumeEnd += Volume[xxxx, yyyy];
// // if (AboveWater[xxxx, yyyy] == 1)
// // {
// // TotalVolAboveEnd += Volume[xxxx, yyyy];
// // }
// // }
// // EndVol.Write(Environment.NewLine);
// //}
// //EndVol.Write(Environment.NewLine + TotalVolumeEnd + ", " + TotalVolAboveEnd);
// //EndVol.Close();
// //StreamWriter XY_End = new StreamWriter("OUTPUT_FILES/MorphChange/XY_End_" + WaveFileTB.Text + ".out");
// //for (int Loop = 0; Loop < X.Length; Loop++)
// //{
// // XY_End.Write(X[Loop] + ", " + Y[Loop] + Environment.NewLine);
// //}
// //XY_End.Close();
// Application.Exit();
// }
// else
// {
// resumeButton_Click(resumeButton, EventArgs.Empty);
// }
//}
//private void Form1_FormClosing(object sender, FormClosingEventArgs e)
//{
// pauseButton_Click(pauseButton, EventArgs.Empty);
// endTime = DateTime.Now.TimeOfDay;
// speed = (endTime - startTime);
// DialogResult Result = MessageBox.Show(("Program at " + (counter - 1) + " days \nDo you want to exit? \n\nSpeed: " + speed.Hours + ":" + speed.Minutes + ":" + speed.Seconds + "(hh:mm:ss)"), " ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
// if (Result == DialogResult.Yes)
// {
// StreamWriter EndVol = new StreamWriter("OUTPUT_FILES/MorphChange/EndVol" + WaveFileTB.Text + ".out");
// EndVol.Write("ncols " + ColumnTB.Text + Environment.NewLine + "nrows " + RowsTB.Text + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
// for (int yyyy = ymax - 1; yyyy >= 0; yyyy--)
// {
// for (int xxxx = 0; xxxx < pbEnd; xxxx++)
// {
// EndVol.Write(Volume[xxxx, yyyy] + " ");
// TotalVolumeEnd += Volume[xxxx, yyyy];
// if (AboveWater[xxxx, yyyy] == 1)
// {
// TotalVolAboveEnd += Volume[xxxx, yyyy];
// }
// }
// EndVol.Write(Environment.NewLine);
// }
// EndVol.Write(Environment.NewLine + TotalVolumeEnd + ", " + TotalVolAboveEnd);
// EndVol.Close();
// StreamWriter XY_End = new StreamWriter("OUTPUT_FILES/MorphChange/XY_End_" + WaveFileTB.Text + ".out");
// for (int Loop = 0; Loop < X.Length; Loop++)
// {
// XY_End.Write(X[Loop] + ", " + Y[Loop] + Environment.NewLine);
// }
// XY_End.Close();
// e.Cancel = false;
// }
// else
// {
// resumeButton_Click(resumeButton, EventArgs.Empty);
// }
//}
void save_data(int typeflag, double tempcycle)
{
int x,y,nn;
string FILENAME = "OUTPUT_FILES/DEM.out";
// turns file name into days from mins.
tempcycle=tempcycle/1440;
if (typeflag == 3 && tempcycle == 0)
{
FILENAME = "DEM_2.out";
}
if(typeflag >= 1 && typeflag < 4)
{
using (StreamWriter sw = new StreamWriter(FILENAME))
{
sw.Write("ncols " + xmax);
sw.Write("\n");
sw.Write("nrows " + (ymax*3));
sw.Write("\n");
for (nn=2; nn<=5; nn++)
{
sw.Write(inputheader[nn]);
sw.Write("\n");
}
for(x = 0; x < xmax; x++)
{
for (y = 0; y < ymax; y++)
{
if (typeflag == 3)
{
sw.Write(PercentFullSand[x, y] + PercentFullRock[x, y]);
sw.Write(" ");
}
}
sw.Write("\n");
}
}
}
}
// ...............CEM FUNCTIONS................................................................................................... //
private void CEMmain(Object sender, EventArgs e)
{
if (counter == 0)
{
ResultsData();
}
//WetDryThreshold = (CellWidth/2) * Math.Tan // or A.tan?((ShorefaceSlope * CellWidth) * (Math.PI/180)); //This will be the local slope, but only using a threshold of 1m at the moment - erosion/depo not dependnt on slope)
// --------------------------------------- PRIMARY PROGRAM LOOP -------------------------------- //
int xx;
int x, y;
// Random Seed - not sure if this is doing anything atm.. leaving it in for now just incase
if (seed == -999)
{
RandZeroToOne();
}
else
{
RandZeroToOne();
}
if (autorestart == 1 && counter == 0)
{
WaveIn = 0;
if (WaveIn == 0)
{
string UA_Wave_Content = File.ReadAllText("INPUT_FILES/UA_WaveClimate/UA_WC_Run_" + Restart_count + ".txt");
UA_Wave_Content = UA_Wave_Content.Replace("\r\n", " ");
UA_Wave_Content = UA_Wave_Content.Replace("\t", " ");
UA_Wave_Content = Regex.Replace(UA_Wave_Content, @"\s+", " ");
UA_Wave_Content = UA_Wave_Content.Replace(",", " ");
UA_Wave_Content = UA_Wave_Content.Trim();
string[] UA_Wave_Split = UA_Wave_Content.Split(' ');
Asym = Convert.ToDouble(UA_Wave_Split[0]);
Highness = Convert.ToDouble(UA_Wave_Split[1]);
Highness = 1 - Highness;
}
else
{ }
}
// FindWaveAngle Outside loop - loop is duration of current wave climate
//if (autorestart == 0)
//{
WaveAngle = FindWaveAngle();
//}
if (Wavedata == 'y')
{
WaveOutFile();
}
//------------------------
// Main Loop
//------------------------
// Loop for Duration at the current wave sign and wave angle
for (xx = 0; xx < Duration; xx++)
{
for (int yyy = ymax - 1; yyy >= 0; yyy--)
{
for (int xxx = 0; xxx < pbEnd; xxx++)
{
PreviousVolume[xxx, yyy] = Volume[xxx, yyy];
VolumeChange[xxx, yyy] = 0;
}
}
if (DoTidesTick.Checked == true)
{
// Set the water level
WLCount++;
if (WLCount > WLArray.Length - 1)
{
//WaterLevel = WLArray[WLArray.Length - 1];
WLCount = 0;
}
else
{
WaterLevel = WLArray[WLCount];
}
}
else
{
WaterLevel = 0;
}
if (DoSLRTick.Checked == true)
{
SLRCount++;
if (SLRCount > SLRArray.Length - 1)
{
WaterLevel += SLR;
}
else
{
WaterLevel += SLRArray[SLRCount];
}
}
PeriodicBoundaryCopy();
ZeroVars();
//------------------------
// Find the Beach (w or w/ tides)
//------------------------
// Initialize for Find Beach Cells (make sure strange beach does not cause trouble)
FellOffArray = 'y';
FindStart = 1;
FellOffRockArray = 'y';
FindRockStart = 0;
// TIDES
if (DoTides == 1)
{
FindTideBeach();
while (FellOffArray == 'y')
{
FindTideBeachCells(FindStart);
FindStart += FindCellError;
if (FindStart > (pbEnd/2))//xDisplayStart + 1)
{
return;
}
}
}
// NO TIDES
else if (DoTides == 0)
{
while (FellOffArray == 'y')
{
// Look for beach - if you fall off of array, bump over a little and try again
FindBeachCells(FindStart);
FindStart += FindCellError;
//// Get Out if no good beach spots exist - finish program
//if (FindStart > (pbEnd / 2))
//{
// FindLooseMaterial();
//}
// Get Out if no good beach spots exist - finish program
if (FindStart > (pbEnd/2))//xDisplayStart + 1)
{
return;
}
}
}
//while (FellOffRockArray == 'y')
//{
// FindRockCells(FindRockStart);
// FindRockStart += FindCellError;
// if (FindRockStart > xDisplayStart + 1)
// {
// return;
// }
//}
//--------------
// Sediment Transport
//--------------
//if (counter == 0)
//{
// StreamWriter OriginalVol = new StreamWriter("OUTPUT_FILES/MorphChange/OriginalVol.out");
// OriginalVol.Write("ncols " + ColumnTB.Text + Environment.NewLine + "nrows " + RowsTB.Text + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
// for (int yyy = ymax - 1; yyy >= 0; yyy--)
// {
// for (int xxx = 0; xxx < pbEnd; xxx++)
// {
// OriginalVol.Write(Volume[xxx, yyy] + " ");
// TotalVolumeStart += Volume[xxx, yyy];
// if (AboveWater[xxx, yyy] == 1)
// {
// TotalVolAboveStart += Volume[xxx, yyy];
// }
// }
// OriginalVol.Write(Environment.NewLine);
// }
// OriginalVol.Write(Environment.NewLine + TotalVolumeStart + ", " + TotalVolAboveStart);
// OriginalVol.Close();
// StreamWriter XY_Start = new StreamWriter("OUTPUT_FILES/MorphChange/XY_Start.out");
// for (int Loop = 0; Loop < X.Length; Loop++)
// {
// XY_Start.Write(X[Loop] + ", " + Y[Loop] + Environment.NewLine);
// }
// XY_Start.Close();
//}
//RockCalculations();
ShadowSweep();
DetermineAngles();
DetermineSedTransport();
//------------------------
// Sources/Sinks
//------------------------
//if (HaveSinks == 1)
//{
// DoSink();
// VolumeRecal();
//}
//if (NumSources >= 1)
//{
// DoSource();
// VolumeRecal();
//}
//------------------------
// More Sediment Transport
//------------------------
//CheckOverwashSweep();
FlowInCell();
FixFlow();
FindAverageShoreface();
TransportSedimentSweep();
VolumeRecal();
//RedrawCoastline();
//FixBeach();
//OopsImDiffusing();
OopsImLandsliding();
//VolumeRecal();
//PeriodicBoundaryCopy();
//------------------------
// Clean Up
//------------------------
// Age Empty Cells
if ((counter % AgeUpdate == 0) && SaveAge == 1)
{
AgeCells();
}
//if (counter == 0)
//{
// SandOutput();
//}
// Save File/Image
if (counter == 0)
{
SaveImageFunct();
}
// Save results data
if (counter % Resuldata_freq == 0)
{
ResultsData();
}
if ((counter % SaveFrequency == 0 && counter > StartSavingAt) || (counter == StopAfter)) //|| (counter > 36500 && counter < 44000 && counter % 365 == 0))
{
//if (SaveLine == 1)
//{
// SaveLineToFile();
//}
//if (SaveFile == 1 || SaveFile == 2)
//{
// SaveSandToFile();
//}
if (SaveImage == 1)
{
SaveImageFunct();
}
}
//SandOutput();
if ((counter == 0 || counter % SaveFrequency == 0) && SaveDEM == 1)
{
// Batch
StreamWriter TElevationDomain_FILE2;
StreamWriter TElevationCS_FILE;
StreamWriter TElevationCS_Above;
StreamWriter TElevationCS_Below;
if (autorestart == 1)
{
TElevationDomain_FILE2 = new StreamWriter("OUTPUT_FILES/Run_" + Restart_count + "/TElevationDomain_File_" + Restart_count + "_" + counter + ".dat");
TElevationCS_FILE = new StreamWriter("OUTPUT_FILES/Run_" + Restart_count + "/TElevationCS_File_" + Restart_count + "_" + counter + ".dat");
TElevationCS_Above = new StreamWriter("OUTPUT_FILES/Run_" + Restart_count + "/TElevationCS_Above_" + Restart_count + "_" + counter + ".dat");
TElevationCS_Below = new StreamWriter("OUTPUT_FILES/Run_" + Restart_count + "/TElevationCS_Below_" + Restart_count + "_" + counter + ".dat");
}
else
{
TElevationDomain_FILE2 = new StreamWriter("OUTPUT_FILES/TElevationDomain_File_" + counter + ".dat");
TElevationCS_FILE = new StreamWriter("OUTPUT_FILES/TElevationCS_File_" + counter + ".dat");
TElevationCS_Above = new StreamWriter("OUTPUT_FILES/TElevationCS_Above_" + counter + ".dat");
TElevationCS_Below = new StreamWriter("OUTPUT_FILES/TElevationCS_Below_" + counter + ".dat");
}
TElevationDomain_FILE2.Write("ncols " + pbEnd + Environment.NewLine + "nrows " + ymax + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
TElevationCS_FILE.Write("ncols " + pbEnd + Environment.NewLine + "nrows " + ymax + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
TElevationCS_Above.Write("ncols " + pbEnd + Environment.NewLine + "nrows " + ymax + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
TElevationCS_Below.Write("ncols " + pbEnd + Environment.NewLine + "nrows " + ymax + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
int r, s;
for (s = ymax - 1; s >= 0; s--)
{
for (r = 0; r < pbEnd; r++)
{
TElevationDomain_FILE2.Write(TElevationDomain[r, s] + " ");
TElevationCS_FILE.Write(TElevationCS[r, s] + " ");
if (AboveWater[r, s] == 1)
{
TElevationCS_Above.Write(TElevationCS[r, s] + " ");
TElevationCS_Below.Write("0 ");
}
else if (AboveWater[r, s] == 0)
{
TElevationCS_Above.Write("0 ");
TElevationCS_Below.Write(TElevationCS[r, s] + " ");
}
else
{
TElevationCS_Above.Write(-9999);
TElevationCS_Below.Write(-9999);
}
}
TElevationDomain_FILE2.Write(Environment.NewLine);
TElevationCS_FILE.Write(Environment.NewLine);
TElevationCS_Above.Write(Environment.NewLine);
TElevationCS_Below.Write(Environment.NewLine);
}
TElevationDomain_FILE2.Close();
TElevationCS_FILE.Close();
TElevationCS_Above.Close();
TElevationCS_Below.Close();
}
counter++;
cycle += time_factor / 60;
// A day!
time_factor = 86400;
// Set the iteration number
this.IterationStatusPanel.Text = "it = " + counter.ToString();
// Set the time
if (cycle <= 1440)
{
this.TimeStatusPanel.Text = string.Format("t = {0:F6} min", cycle); // O is the placeholder, F6 is the format (fixed point, 6 decimal digits)
}
else
{
this.TimeStatusPanel.Text = string.Format("t = {0:F6} day", cycle / 1440);
}
// save data every specified interval. Passes the cycle which becomes the file extension
if (cycle >= save_time)
{
save_time += saveinterval;
}
hit = 0;
// --------------------------------------- END OF CEM MAIN --------------------------------------------------
//------------------------
// Have we reached the end?
//------------------------
if (counter == (StopAfter + 1))
{
// Batch
if (autorestart == 1)
{
if (Restart_count <= maxRuns)
{
Application.Restart();
}
else
{
StreamWriter Restart_count_zero = new StreamWriter("OUTPUT_FILES/Restart_Count_FILE.txt");
Restart_count_zero.Write("0");
Restart_count_zero.Close();
}
Application.Exit();
}
else
{
endTime = DateTime.Now.TimeOfDay;
speed = (endTime - startTime);
DialogResult Result = MessageBox.Show(("Program at " + (counter - 1) + " days \nDo you want to exit? \n\nSpeed: " + speed.Hours + ":" + speed.Minutes + ":" + speed.Seconds + "(hh:mm:ss)"), " ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
if (Result == DialogResult.Yes)
{
StreamWriter EndVol = new StreamWriter("OUTPUT_FILES/MorphChange/EndVol" + WaveFileTB.Text + ".out");
EndVol.Write("ncols " + ColumnTB.Text + Environment.NewLine + "nrows " + RowsTB.Text + Environment.NewLine + "xllcorner 0" + Environment.NewLine + "yllcorner 0" + Environment.NewLine + "cellsize 100" + Environment.NewLine + "NODATA_value -9999" + Environment.NewLine);
for (int yyyy = ymax - 1; yyyy >= 0; yyyy--)
{
for (int xxxx = 0; xxxx < pbEnd; xxxx++)
{
EndVol.Write(Volume[xxxx, yyyy] + " ");
TotalVolumeEnd += Volume[xxxx, yyyy];
if (AboveWater[xxxx, yyyy] == 1)
{
TotalVolAboveEnd += Volume[xxxx, yyyy];
}
}
EndVol.Write(Environment.NewLine);
}
EndVol.Write(Environment.NewLine + TotalVolumeEnd + ", " + TotalVolAboveEnd);
EndVol.Close();
StreamWriter XY_End = new StreamWriter("OUTPUT_FILES/MorphChange/XY_End_" + WaveFileTB.Text + ".out");
for (int Loop = 0; Loop < X.Length; Loop++)
{
XY_End.Write(X[Loop] + ", " + Y[Loop] + Environment.NewLine);
}
XY_End.Close();
Application.Exit();
}
}
}
}
}
// Set Up
void PeriodicBoundaryCopy()
{
// Simulates periodic boundary conditions by copying middle section to front and end of arrays
int x, y;
for (x = xmax; x < xDisplayEnd; x++)
{
for (y = 0; y < ymax; y++)
{
//AllBeach[x - xmax, y] = AllBeach[x, y];
AllRock[x - xmax, y] = AllRock[x, y];
TypeOfRock[x - xmax, y] = TypeOfRock[x, y];
PercentFullSand[x - xmax, y] = PercentFullSand[x, y];
PercentFullRock[x - xmax, y] = PercentFullRock[x, y];
AboveTideOLD[x - xmax, y] = AboveTideOLD[x, y];
AboveWater[x - xmax, y] = AboveWater[x, y];
ShorelineCell[x - xmax, y] = ShorelineCell[x, y];
Linear_Shoreline[x - xmax, y] = Linear_Shoreline[x, y];
Age[x - xmax, y] = Age[x, y];
Elevation[x - xmax, y] = Elevation[x, y];
Volume[x - xmax, y] = Volume[x, y];
PreviousVolume[x - xmax, y] = PreviousVolume[x, y];
VolumeChange[x - xmax, y] = VolumeChange[x, y];
DepthShelf[x - xmax, y] = DepthShelf[x, y];
DepthShelfMaterial[x - xmax, y] = DepthShelfMaterial[x, y];
WaterDepth0[x - xmax, y] = WaterDepth0[x, y];
DomainDepthCS[x - xmax, y] = DomainDepthCS[x, y];
TElevationCS[x - xmax, y] = TElevationCS[x, y];
TElevationDomain[x - xmax, y] = TElevationDomain[x, y];
}
}
for (x = xDisplayStart; x < xmax; x++)
{
for (y = 0; y < ymax; y++)
{
//AllBeach[x + xmax, y] = AllBeach[x, y];
AllRock[x + xmax, y] = AllRock[x, y];
TypeOfRock[x + xmax, y] = TypeOfRock[x, y];
PercentFullSand[x + xmax, y] = PercentFullSand[x, y];
PercentFullRock[x + xmax, y] = PercentFullRock[x, y];
AboveTideOLD[x + xmax, y] = AboveTideOLD[x, y];
AboveWater[x + xmax, y] = AboveWater[x, y];
ShorelineCell[x + xmax, y] = ShorelineCell[x, y];
Linear_Shoreline[x + xmax, y] = Linear_Shoreline[x, y];
Age[x + xmax, y] = Age[x, y];
Elevation[x + xmax, y] = Elevation[x, y];
Volume[x + xmax, y] = Volume[x, y];
PreviousVolume[x + xmax, y] = PreviousVolume[x, y];
VolumeChange[x + xmax, y] = VolumeChange[x, y];
DepthShelf[x + xmax, y] = DepthShelf[x, y];
DepthShelfMaterial[x + xmax, y] = DepthShelfMaterial[x, y];
WaterDepth0[x + xmax, y] = WaterDepth0[x, y];
DomainDepthCS[x + xmax, y] = DomainDepthCS[x, y];
TElevationCS[x + xmax, y] = TElevationCS[x, y];
TElevationDomain[x + xmax, y] = TElevationDomain[x, y];
}
}
//for (int i = 0; i < 100; i++)
//{
// Elevation[0, i] = 60;
// TElevationCS[0, i] = DepthShelf[0, i] + Elevation[0, i];
// TElevationDomain[0, i] = TElevationCS[0, i] + DomainDepthCS[0, i];
// Volume[0, i] = TElevationCS[0, i] * CellWidth * CellWidth;
// PreviousVolume[0, i] = Volume[0, i];
// WaterDepth0[0, i] = 0;
// AboveWater[0, i] = 1;
// Elevation[1, i] = 60;
// TElevationCS[1, i] = DepthShelf[1, i] + Elevation[1, i];
// TElevationDomain[1, i] = TElevationCS[1, i] + DomainDepthCS[0, i];
// Volume[1, i] = TElevationCS[1, i] * CellWidth * CellWidth;
// PreviousVolume[0, i] = Volume[0, i];
// WaterDepth0[1, i] = 0;
// AboveWater[1, i] = 1;
//}
////StreamWriter AbovWater = new StreamWriter("OUTPUT_FILES/abovpb.out");
////for (y = ymax - 1; y >= 0; y--)
////{
//// for (x = xDisplayStart; x < xDisplayEnd; x++)
//// {
//// AbovWater.Write(AboveWater[x, y] + " ");
//// }
//// AbovWater.Write(Environment.NewLine);
////}
////AbovWater.Close();
////updateGraphics_Click_1(updateGraphicsButton, EventArgs.Empty);
}
void AgeCells()
{
//// Age Cells
//int x, y;
//for (x = 0; x < pbEnd; x++)
//{
// for (y = 0; y < ymax; y++)
// {
// if (PercentFullSand[x, y] == 0)
// {
// Age[x, y] = counter % AgeMax;
// }
// }
//}
}
// Computer-Generated DEM
void InitConds()
{
//counter = 0;
//if (InitCType == 0)
//{
// InitNormal();
//}
//else if (InitCType == 1)
//{
// while (InitWiggly() == -1)
// {
// }
//}
//else if (InitCType == 2)
//{
// initBlock();
//}
//if (InitialPert != 0)
//{
// InitPert();
//}
//else
//{
// MessageBox.Show("Error InitConds");
//}
//return;
}
void InitNormal()
{
//// Creates initial beach conditions
//// Flat beach with zone of AllBeach = 'y' separated by AllBeach = 'n'
//// Block of rock parallel to beach begins at InitRock LMV
//// LMV Assume that AllBeach = 'Y' for AllRock cells (and All Full cells)
//// Bounding layer set to random fraction of fullness
//int x, y, n;
//int InitialBeach;
//int InitialRock = 0;
//int Amp; // Amplitude of cos curve
//int blocks = 1; // Have hard stuff just as blocks near the beach, or columns?
//Amp = 10;
//for (x = 0; x < pbEnd; x++)
//{
// for (y = 0; y < ymax; y++)
// {
// InitialBeach = InitBeach;
// InitialRock = InitRock;
// // shoreline is a cosine curve, diffusive LMV
// if (DiffusiveHump == 1)
// {
// InitialRock = Convert.ToInt32((InitRock + (-Amp * Math.Cos((2 * pi * x) / xmax)) - (InitBeach - InitRock - 1)));
// InitialBeach = Convert.ToInt32((InitBeach + (-Amp * Math.Cos((2 * pi * x) / xmax))));
// }
// if (y < InitialRock)
// {
// PercentFullRock[x, y] = 1.0;
// PercentFullSand[x, y] = 0.0;
// AllRock[x, y] = 1;
// AllBeach[x, y] = 0;
// }
// else if (y == InitialRock)
// {
// if (InitialSmoothRock == 1)
// {
// PercentFullRock[x, y] = 0.20;
// PercentFullSand[x, y] = 0.80;
// }
// else
// {
// PercentFullRock[x, y] = RandZeroToOne();
// PercentFullSand[x, y] = 1 - PercentFullRock[x, y];
// }
// AllRock[x, y] = 0;
// AllBeach[x, y] = 1;
// }
// else if ((y > InitialRock) && (y < InitialBeach))
// {
// PercentFullRock[x, y] = 0.0;
// PercentFullSand[x, y] = 1.0;
// AllRock[x, y] = 0;
// AllBeach[x, y] = 0;
// }
// else if (y == InitialBeach)
// {
// if (InitialSmooth == 1)
// {
// PercentFullSand[x, y] = 0.5;
// }
// else
// {
// PercentFullSand[x, y] = RandZeroToOne();
// }
// AllRock[x, y] = 0;
// AllBeach[x, y] = 0;
// }
// else if (y > InitialBeach)
// {
// PercentFullSand[x, y] = 0;
// AllRock[x, y] = 0;
// AllBeach[x, y] = 0;
// }
// Age[x, y] = 0;
// }
//}
//if (NumberChunk != 0)
//{
// for (y = 0; y <= ymax; y++) // Assign fast and slow weathering portions
// {
// for (n = 0; n <= 2 * NumberChunk; n++)
// {
// for (x = n * ChunkLength; x < ((n + 2) * ChunkLength); x++)
// {
// if (n % 3 == 0 && (blocks == 0 || x > InitialRock - 3))
// // if even
// {
// TypeOfRock[x, y] = 's';
// }
// else
// // if odd
// {
// TypeOfRock[x, y] = 'f';
// }
// }
// }
// }
//}
//else //make everything fast
//{
// for (y = 0; y < ymax; y++)
// {
// for (x = 0; x < xDisplayEnd; x++)
// {
// TypeOfRock[x, y] = 'f';
// }
// }
//}
}
void InitPert()
{
//// Andrew's initial bump
//int x, y;
//int PWidth;
//int PHeight;
//int PYstart;
//// Square perturbation
//if (InitialPert == 1)
//{
// PWidth = (xmax / (xmax / 2));
// PHeight = PWidth;
// PYstart = 2;
// // Fill AllBeach areas
// while ((PYstart + PWidth) < pbEnd)
// {
// for (y = InitBeach; y < InitBeach + PHeight; y++)
// {
// for (x = PYstart; x < PYstart + PWidth; x++)
// {
// PercentFullSand[x, y] = 1.0;
// AllBeach[x, y] = 1;
// }
// }
// //// PercentFull Top
// //for (x = PYstart - 1; x <= PYstart + PWidth + 1; x++)
// //{
// // PercentFullSand[x, InitBeach + PHeight + 1] = RandZeroToOne();
// //}
// //// PercentFull Sides
// //for (y = InitBeach; y <= InitBeach + PHeight; y++)
// //{
// // PercentFullSand[PYstart - 1, y] = RandZeroToOne();
// // PercentFullSand[PYstart + PWidth + 1, y] = RandZeroToOne();
// //}
// PYstart = PYstart + (PWidth * 3);
// }
//}
//// Another Perturbation - steep point
//else if (InitialPert == 2)
//{
// y = InitBeach;
// PercentFullSand[17, y] = 0.8;
// PercentFullSand[18, y] = 1.0;
// AllBeach[18, y] = 1;
// PercentFullSand[19, y] = 0.8;
// y = InitBeach + 1;
// PercentFullSand[17, y] = 0.6;
// PercentFullSand[18, y] = 1.0;
// AllBeach[18, y] = 1;
// PercentFullSand[19, y] = 0.6;
// y = InitBeach + 2;
// PercentFullSand[17, y] = 0.2;
// PercentFullSand[18, y] = 1.0;
// AllBeach[18, y] = 1;
// PercentFullSand[19, y] = 0.2;
// y = InitBeach + 3;
// PercentFullSand[18, y] = 0.3;
//}
//// Square perturbation
//else if (InitialPert == 3)
//{
// PWidth = xmax / (xmax / 10);
// PHeight = PWidth / 2;
// PYstart = xmax - (PWidth / 2);
// for (y = InitBeach; y < InitBeach + PHeight; y++)
// {
// for (x = PYstart; x < PYstart + PWidth; x++)
// {
// PercentFullSand[x, y] = 1.0;
// AllBeach[x, y] = 1;
// }
// }
// //// PercentFull Top
// //for (x = PYstart - 1; x <= PYstart + PWidth + 1; x++)
// //{
// // PercentFullSand[x, InitBeach + PHeight + 1] = RandZeroToOne();
// //}
// //// PercentFull Sides
// //for (y = InitBeach; y <= InitBeach + PHeight; y++)
// //{
// // PercentFullSand[PYstart - 1, y] = RandZeroToOne();
// // PercentFullSand[PYstart + PWidth + 1, y] = RandZeroToOne();
// //}
//}
}
//CM: Comp-generated, but having issues getting these to work using InitPert instead at the moment
int InitWiggly()
{
//int x, y, curve;
//int NumCurves = 4;
//double[] RockLine = new double[pbEnd];
//int curveFactor = 3; // decrease fundamental wavelength/increase frequency (by a factor) -- make it 1 for wavelength = xmax
//double Amp, AmpMax = InitRock / 6.0; // maximum amplitude of the component sin waves
//int Min = Convert.ToInt32(0.10 * ymax);
//int Max = Convert.ToInt32(0.95 * ymax); // determines acceptable max amplitude of resulting curve
//double[] BeachLine = new double[pbEnd];
//for (x = 0; x < pbEnd; x++)
//{
// RockLine[x] = InitRock;
//}
//for (curve = 1; curve <= NumCurves; curve++)
//{
// Amp = RandZeroToOne() * AmpMax;
// for (x = 1; x < pbEnd; x++)
// {
// RockLine[x] = Math.Ceiling(RockLine[x] + (Amp * Math.Sin(x * (curve * curveFactor) * 2.0 * pi / xmax)));
// BeachLine[x] = RockLine[x] + 1;
// if (RockLine[x] < Min || RockLine[x] > Max)
// {
// return -1;
// }
// }
//}
//for (y = 0; y < ymax; y++)
//{
// for (x = 0; x < pbEnd; x++)
// //{
// // if (y < RockLine[x])
// // {
// // PercentFullRock[x, y] = 1.0;
// // PercentFullSand[x, y] = 0.0;
// // AllRock[x, y] = 'y';
// // TypeOfRock[x, y] = 's';
// // AllBeach[x, y] = 'y';
// // }
// // else if (y == RockLine[x])
// // {
// // PercentFullRock[x, y] = 0.5;
// // PercentFullSand[x, y] = 0.5;
// // AllRock[x, y] = 'n';
// // AllBeach[x, y] = 'n';
// // }
// // else
// // {
// // PercentFullRock[x, y] = 0.0;
// // PercentFullSand[x, y] = 0.0;
// // AllRock[x, y] = 'n';
// // AllBeach[x, y] = 'n';
// // }
// // if (y == BeachLine[x])
// // {
// // PercentFullSand[x, y] = 1.0;
// // }
// // Age[x, y] = 0;
// //}
// //}
// {
// TypeOfRock[x, y] = 's';
// if (y < RockLine[x])
// {
// PercentFullRock[x, y] = 1.0;
// PercentFullSand[x, y] = 0.0;
// AllRock[x, y] = 1;
// AllBeach[x, y] = 1;
// }
// else if (y == RockLine[x])
// {
// PercentFullRock[x, y] = 0.0;
// PercentFullSand[x, y] = 0.5;
// AllRock[x, y] = 0;
// AllBeach[x, y] = 0;
// }
// else
// {
// PercentFullRock[x, y] = 0.0;
// PercentFullSand[x, y] = 0.0;
// AllRock[x, y] = 0;
// AllBeach[x, y] = 0;
// }
// Age[x, y] = 0;
// }
//}
return 0;
}
int initBlock()
{
//int x, y, n;
//int blockHeight = 4;
//int NumBlocks = 2; // makes NumBlocks evenly spaced blocks
//int blockWidth = (xmax / (NumBlocks * 2));
//for (y = 0; y < ymax; y++)
//{
// for (x = 0; x < pbEnd; x++)
// {
// TypeOfRock[x, y] = 'f';
// if (y < InitRock)
// {
// PercentFullRock[x, y] = 1.0;
// PercentFullSand[x, y] = 0.0;
// AllRock[x, y] = 1;
// AllBeach[x, y] = 1;
// }
// else if (y < InitBeach)
// {
// PercentFullRock[x, y] = 0.0;
// PercentFullSand[x, y] = 1.0;
// AllRock[x, y] = 0;
// AllBeach[x, y] = 1;
// }
// else if (y == InitBeach)
// {
// PercentFullRock[x, y] = 0.0;
// PercentFullSand[x, y] = RandZeroToOne();
// AllRock[x, y] = 0;
// AllBeach[x, y] = 0;
// }
// else
// {
// PercentFullRock[x, y] = 0.0;
// PercentFullSand[x, y] = 0.0;
// AllRock[x, y] = 0;
// AllBeach[x, y] = 0;
// }
// Age[x, y] = 0;
// }
//}
//// the regularly-spaced blocks
//for (n = 1; n <= NumBlocks; n++)
//{
// for (y = InitRock; y >= InitRock - blockHeight; y--)
// {
// // block starts @ upper left corner
// for (x = xDisplayStart + n * xmax / (NumBlocks + 1); x < xDisplayStart + n * xmax / (NumBlocks + 1) + blockWidth && x < pbEnd; x++)
// {
// PercentFullRock[x, y] = 1.0;
// PercentFullSand[x, y] = 0.0;
// AllRock[x, y] = 1;
// TypeOfRock[x, y] = 's';
// AllBeach[x, y] = 1;
// }
// }
//}
//// now here's space for ad hoc blocks
//// ad hoc block 1
//for (y = InitRock; y >= InitRock - blockHeight; y--)
//{
// for (x = xDisplayStart; x < xDisplayStart + 10; x++)
// {
// PercentFullRock[x, y] = 1.0;
// PercentFullSand[x, y] = 0.0;
// AllRock[x, y] = 1;
// TypeOfRock[x, y] = 's';
// AllBeach[x, y] = 1;
// }
//}
//// ad hoc block 2
//for (y = InitRock; y >= InitRock - blockHeight; y--)
//{
// for (x = xDisplayEnd - 90; x < xDisplayEnd; x++)
// {
// PercentFullRock[x, y] = 1.0;
// PercentFullSand[x, y] = 0.0;
// AllRock[x, y] = 1;
// TypeOfRock[x, y] = 's';
// AllBeach[x, y] = 1;
// }
//}
return 0;
}
// Get Wave Climate
double FindWaveAngle()
{
// calculates wave angle for given time step
double Angle = 0.0;
double RandBin; // Random number to pick wave angle bin
double RandAngle; // Random number to pick wave angle within the bin
int flag = 1;
int i = 0;
if (WaveIn == 0)
{
// Method using wave probability step function
// variable Asym will determine fractional distribution of waves coming from the
// positive direction (positive direction coming from left) -i.e. fractional wave asymmetry
// Note: Highness actually means lowness, for some reason
Angle = RandZeroToOne() * pi / 4.0;
if (RandZeroToOne() >= Highness)
{
Angle += pi / 4.0; // make high angle
}
if (RandZeroToOne() >= Asym)
{
Angle = -1.0 * Angle;
}
}
// Method using input binned wave distribution - variables: WaveProb[], WaveMax[], previously input from file using ReadWaveIn()
if (WaveIn == 1)
{
RandBin = RandZeroToOne();
RandAngle = RandZeroToOne();
while (flag == 1)
{
i++;
if (RandBin < WaveProb[i])
{
flag = 0;
}
}
Angle = -(RandAngle * (WaveMax[i] - WaveMax[i - 1]) + WaveMax[i - 1]) * pi / 180;
}
if (WaveIn == 2)
{
RealWaveIn(); // Read real data (angle/period/height)
Angle = WaveAngleIn + coastrotation; // Align waveclimate to coastline in CEM
//if (Angle >= 180.0)
//{
// Angle -= 360.0; // Conversion to CEM angles (-180 -- 0 -- +180)
//}
////Angle *= -1; // -1 is there as wave angle is from 90 in the west to -90 in the east
//Period = WavePeriodIn * waveperiodchange;
//OffShoreWvHt = WaveHeightIn * waveheightchange;
//if ((Angle > 90) || (Angle < -90))
//{
// Angle = 0; // if waves were to come from behind coast*/
// OffShoreWvHt = 1e-10; // if waves were to come from behind coast set to inf small
//}
//ADDED
Period = WavePeriodIn;
OffShoreWvHt = WaveHeightIn;
Angle /= radtodeg;
}
if (WaveIn == 3)
{
WaveAngleIn = Convert.ToDouble(this.WAngleTB.Text);
WavePeriodIn = Convert.ToDouble(this.WPeriodTB.Text);
WaveHeightIn = Convert.ToDouble(this.WHeightTB.Text);
Angle = WaveAngleIn + coastrotation; // Align waveclimate to coastline in CEM
if (Angle >= 180.0)
{
Angle -= 360.0; // Conversion to CEM angles (-180 -- 0 -- +180)
}
//Angle *= -1; // -1 is there as wave angle is from 90 in the west to -90 in the east
Period = WavePeriodIn * waveperiodchange;
OffShoreWvHt = WaveHeightIn * waveheightchange;
if ((Angle > 90) || (Angle < -90))
{
Angle = 0; // if waves were to come from behind coast*/
OffShoreWvHt = 1e-10; // if waves were to come from behind coast set to inf small
}
Angle /= radtodeg;
}
return Angle;
}
void RealWaveIn()
{
// Input real wave data from file
// Batch
if (autorestart == 1)
{
readwavename = "INPUT_FILES/WaveClimate/WaveClimate_" + Restart_count + ".dat";
this.WaveFileTB.Text = "WaveClimate_" + Restart_count;
}
else
{
readwavename = "INPUT_FILES/WaveClimate/" + this.WaveFileTB.Text;
}
//WaveAngleIn = 67.5;
//WavePeriodIn = 6.65;
//WaveHeightIn = 1.85;
if (counter == 0)
{
StreamReader ReadWaveFile = new StreamReader(readwavename);
realWave_Content = File.ReadAllText(readwavename);
realWave_Content = realWave_Content.Replace("\r\n", " ");
realWave_Content = realWave_Content.Replace("\t", " ");
realWave_Content = Regex.Replace(realWave_Content, @"\s+", " ");
realWave_Content = realWave_Content.Trim();
realWave_Split = realWave_Content.Split(' ');
ReadWaveFile.Close();
Wavecount = 0;
}
if (Wavecount == realWave_Split.Length)
{
Wavecount = 0;
}
WaveAngleIn = Convert.ToDouble(realWave_Split[Wavecount]);
Wavecount++;
WavePeriodIn = Convert.ToDouble(realWave_Split[Wavecount]);
Wavecount++;
WaveHeightIn = Convert.ToDouble(realWave_Split[Wavecount]);
Wavecount++;
}
void ReadWaveIn()
{
// ////// HAVE NOT YET CONVERTED!!!!!!!!!!!!!!!!!!!!!!!!!
// //// /*
// //// // Input Wave Distribution
// //// int i;
// //// StreamReader ReadWaveFile = new StreamReader(readwavename);
// //// for (i = 0; i <= 36; i++)
// //// {
// //// WaveMax[i] = 0;
// //// WaveProb[i] = 0;
// //// }
// //// NumWaveBins = ReadWaveFile.Read();
// //// fscanf(ReadWaveFile, " %d \n", &NumWaveBins);
// //// printf("Wave Bins %d \n",NumWaveBins);
// //// WaveMax[0] = -90;
// //// WaveProb[0] = 0;
// //// for (i=1 ; i<= NumWaveBins ; i++)
// //// {
// //// fscanf(ReadWaveFile, " %f %f", &WaveMax[i] , &WaveProb[i]);
// //// printf("i= %d Wave= %f Prob= %f \n",i, WaveMax[i], WaveProb[i]);
// //// }
// //// fclose(ReadWaveFile);
// //// printf("wave file read! \n");
// //// */
}
// Beach Misc
double MassCount()
{
//// Counts the total volume occupied by beach cells
//// Uses same algorhythm as AdjustShore
//// returns a float of the total sum
//// Uses AllBeach[][] and PercentFullSand[][]
//// and InitialDepth, CellWidth, ShelfSlope
//int x, y;
//double DepthMC; // Depth of current cell
double Mass = 0.0;
//for (y = 0; y < ymax; y++)
//{
// DepthMC = InitialDepth + ((y - InitBeach) * CellWidth * ShelfSlope);
// for (x = 0; x < pbEnd; x++)
// {
// Mass += PercentFullSand[x, y] * DepthMC;
// }
//}
return Mass;
}
// Find shoreline cells - with tides
void FindTideBeach()
{
int x, y, i;
// Don't need this beacuse only the shorelne ones will change
for (y = 0; y < ymax; y++)
{
for (x = 0; x < pbEnd; x++)
{
if (TElevationDomain[x, y] >= WaterLevel + maxDomainDepth + WDThreshold)
{
AboveWater[x, y] = 1;
}
else
{
AboveWater[x, y] = 0;
}
}
}
}
void FindTideBeachCells(int Xstart)
{
// Determines locations of beach cells moving from left to right direction
// This function will affect and determine the global arrays: X[] and Y[]
// This function calls FindNextCell
// This will define TotalBeachCells for this time step
int x = Xstart;
int ystart = ymax - 1;
int z = 1;
// Finding the start position of the tide beach
//while (AboveTideOLD[x, ystart] == false)
while (AboveWater[x, ystart] == 0)
{
ystart -= 1;
}
//ystart += 1;
X[0] = Xstart;
Y[0] = ystart + 1;
//Need to give these some values for 'weathered rock'
XBehind[0] = X[0];
YBehind[0] = Y[0];
ystart = ymax - 1;
//while (AboveTideOLD[x + 1, ystart] == false)
while (AboveWater[x + 1, ystart] == 0)
{
ystart -= 1;
}
//ystart += 1;
X[1] = Xstart + 1;
Y[1] = ystart + 1;
XBehind[1] = X[0];
YBehind[1] = Y[0];
while ((X[z] < pbEnd - 1) && (z < MaxBeachLength - 1))
{
z++;
NextX = -2;
NextY = -2;
BehindX = -2;
BehindY = -2;
FindNextTideCell(X[z - 1], Y[z - 1], z - 1);
X[z] = NextX;
Y[z] = NextY;
XBehind[z] = BehindX;
YBehind[z] = BehindY;
//Print to file X[] and Y[] Arrays
//XYFile.Write(counter + " " + z + " " + X[z] + " " + Y[z] + Environment.NewLine);
// If return to start point or go off left side of array, going the wrong direction
// Jump off and start again closer to middle
if ((NextX < 1) || ((NextX == X[0]) && (NextY == Y[0])) || (z > MaxBeachLength - 2))
{
FellOffArray = 'y';
ZeroVars();
return;
}
}
TotalBeachCells = z;
FellOffArray = 'n';
if(counter == 0)
{
Array.Copy(X, initialX, X.Length);
Array.Copy(Y, initialY, Y.Length);
}
Array.Clear(ShorelineCell, 0, ShorelineCell.Length);
for (int ii = 0; ii < TotalBeachCells; ii++)
{
ShorelineCell[X[ii], Y[ii]] = 1;
}
//XYFile.Close();
}
//void FindNextTideCell(int x, int y, int z)
//{
// // Function to find next cell that is beach moving in the general positive X direction
// // changes global variables NextX and NextY, coordinates for the next beach cell
// // This function will use but not affect the global arrays: AllBeach [][], X[], and Y[]
// // Came from left
// if ((Y[z - 1] == Y[z]) && (X[z - 1] == X[z] - 1))
// {
// // Top
// if (AboveTideOLD[x, y + 1] == true)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Right
// else if (AboveTideOLD[x + 1, y + 1] == true)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Right
// else if (AboveTideOLD[x + 1, y] == true)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Right
// else if (AboveTideOLD[x + 1, y - 1] == true)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom
// else if (AboveTideOLD[x, y - 1] == true)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Left
// else if (AboveTideOLD[x - 1, y - 1] == true)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Left
// else if (AboveTideOLD[x - 1, y] == true)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// }
// // Came from top left
// else if ((Y[z - 1] == Y[z] + 1) && (X[z - 1] == X[z] - 1))
// {
// // Top Right
// if (AboveTideOLD[x + 1, y + 1] == true)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Right
// else if (AboveTideOLD[x + 1, y] == true)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Right
// else if (AboveTideOLD[x + 1, y - 1] == true)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom
// else if (AboveTideOLD[x, y - 1] == true)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Left
// else if (AboveTideOLD[x - 1, y - 1] == true)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Left
// else if (AboveTideOLD[x - 1, y] == true)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Left
// else if (AboveTideOLD[x - 1, y + 1] == true)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// }
// // Came from above
// else if ((Y[z - 1] == Y[z] + 1) && (X[z - 1] == X[z]))
// {
// // Right
// if (AboveTideOLD[x + 1, y] == true)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Right
// else if (AboveTideOLD[x + 1, y - 1] == true)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom
// else if (AboveTideOLD[x, y - 1] == true)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Left
// else if (AboveTideOLD[x - 1, y - 1] == true)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Left
// else if (AboveTideOLD[x - 1, y] == true)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top left
// else if (AboveTideOLD[x - 1, y + 1] == true)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Above
// else if (AboveTideOLD[x, y + 1] == true)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// }
// // Came from upper right
// else if ((Y[z - 1] == Y[z] + 1) && (X[z - 1] == X[z] + 1))
// {
// // Bottom Right
// if (AboveTideOLD[x + 1, y - 1] == true)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom
// else if (AboveTideOLD[x, y - 1] == true)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom left
// else if (AboveTideOLD[x - 1, y - 1] == true)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Left
// else if (AboveTideOLD[x - 1, y] == true)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Left
// else if (AboveTideOLD[x - 1, y + 1] == true)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top
// else if (AboveTideOLD[x, y + 1] == true)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Upper Right
// else if (AboveTideOLD[x + 1, y + 1] == true)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// }
// // Came from right
// else if ((Y[z - 1] == Y[z]) && (X[z - 1] == X[z] + 1))
// {
// // Bottom
// if (AboveTideOLD[x, y - 1] == true)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom left
// else if (AboveTideOLD[x - 1, y - 1] == true)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Left
// else if (AboveTideOLD[x - 1, y] == true)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Left
// else if (AboveTideOLD[x - 1, y + 1] == true)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top
// else if (AboveTideOLD[x, y + 1] == true)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Right
// else if (AboveTideOLD[x + 1, y + 1] == true)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Right
// else if (AboveTideOLD[x + 1, y] == true)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// }
// // Came from lower right
// else if ((Y[z - 1] == Y[z] - 1) && (X[z - 1] == X[z] + 1))
// {
// // Bottom left
// if (AboveTideOLD[x - 1, y - 1] == true)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Left
// else if (AboveTideOLD[x - 1, y] == true)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Left
// else if (AboveTideOLD[x - 1, y + 1] == true)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top
// else if (AboveTideOLD[x, y + 1] == true)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Right
// else if (AboveTideOLD[x + 1, y + 1] == true)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Right
// else if (AboveTideOLD[x + 1, y] == true)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// else if (AboveTideOLD[x + 2, y] == true
// || AboveTideOLD[x + 2, y - 1] == true
// || AboveTideOLD[x + 2, y + 1] == true)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // LowerRight
// else if (AboveTideOLD[x + 1, y - 1] == true)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// }
// // Came from below
// else if ((Y[z - 1] == Y[z] - 1) && (X[z - 1] == X[z]))
// {
// // Left
// if (AboveTideOLD[x - 1, y] == true)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top left
// else if (AboveTideOLD[x - 1, y + 1] == true)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top
// else if (AboveTideOLD[x, y + 1] == true)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Right
// else if (AboveTideOLD[x + 1, y + 1] == true)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Right
// else if (AboveTideOLD[x + 1, y] == true)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Right
// else if (AboveTideOLD[x + 1, y - 1] == true)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Below
// else if (AboveTideOLD[x, y - 1] == true)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// }
// // Came from bottom left
// else if ((Y[z - 1] == Y[z] - 1) && (X[z - 1] == X[z] - 1))
// {
// // Top Left
// if (AboveTideOLD[x - 1, y + 1] == true)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top
// else if (AboveTideOLD[x, y + 1] == true)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Right
// else if (AboveTideOLD[x + 1, y + 1] == true)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Right
// else if (AboveTideOLD[x + 1, y] == true)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Right
// else if (AboveTideOLD[x + 1, y - 1] == true)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom
// else if (AboveTideOLD[x, y - 1] == true)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Left
// else if (AboveTideOLD[x - 1, y - 1] == true)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// }
//}
/* This version is for the volumes */
void FindNextTideCell_1(int x, int y, int z)
{
// Function to find next cell that is beach moving in the general positive X direction
// changes global variables NextX and NextY, coordinates for the next beach cell
// This function will use but not affect the global arrays: AllBeach [][], X[], and Y[]
// Came from left
if ((Y[z - 1] == Y[z]) && (X[z - 1] == X[z] - 1))
{
// Top
if (AboveWater[x, y + 1] == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top Right
else if (AboveWater[x + 1, y + 1] == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Right
else if (AboveWater[x + 1, y] == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Right
else if (AboveWater[x + 1, y - 1] == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom
else if (AboveWater[x, y - 1] == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Left
else if (AboveWater[x - 1, y - 1] == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Left
else if (AboveWater[x - 1, y] == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
}
// Came from top left
else if ((Y[z - 1] == Y[z] + 1) && (X[z - 1] == X[z] - 1))
{
// Top Right
if (AboveWater[x + 1, y + 1] == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Right
else if (AboveWater[x + 1, y] == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Right
else if (AboveWater[x + 1, y - 1] == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom
else if (AboveWater[x, y - 1] == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Left
else if (AboveWater[x - 1, y - 1] == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Left
else if (AboveWater[x - 1, y] == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top Left
else if (AboveWater[x - 1, y + 1] == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
}
// Came from above
else if ((Y[z - 1] == Y[z] + 1) && (X[z - 1] == X[z]))
{
// Right
if (AboveWater[x + 1, y] == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Right
else if (AboveWater[x + 1, y - 1] == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom
else if (AboveWater[x, y - 1] == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Left
else if (AboveWater[x - 1, y - 1] == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Left
else if (AboveWater[x - 1, y] == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top left
else if (AboveWater[x - 1, y + 1] == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Above
else if (AboveWater[x, y + 1] == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
}
// Came from upper right
else if ((Y[z - 1] == Y[z] + 1) && (X[z - 1] == X[z] + 1))
{
// Bottom Right
if (AboveWater[x + 1, y - 1] == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom
else if (AboveWater[x, y - 1] == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom left
else if (AboveWater[x - 1, y - 1] == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Left
else if (AboveWater[x - 1, y] == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top Left
else if (AboveWater[x - 1, y + 1] == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top
else if (AboveWater[x, y + 1] == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Upper Right
else if (AboveWater[x + 1, y + 1] == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
}
// Came from right
else if ((Y[z - 1] == Y[z]) && (X[z - 1] == X[z] + 1))
{
// Bottom
if (AboveWater[x, y - 1] == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom left
else if (AboveWater[x - 1, y - 1] == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Left
else if (AboveWater[x - 1, y] == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top Left
else if (AboveWater[x - 1, y + 1] == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top
else if (AboveWater[x, y + 1] == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top Right
else if (AboveWater[x + 1, y + 1] == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Right
else if (AboveWater[x + 1, y] == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
}
// Came from lower right
else if ((Y[z - 1] == Y[z] - 1) && (X[z - 1] == X[z] + 1))
{
// Bottom left
if (AboveWater[x - 1, y - 1] == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Left
else if (AboveWater[x - 1, y] == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top Left
else if (AboveWater[x - 1, y + 1] == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top
else if (AboveWater[x, y + 1] == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top Right
else if (AboveWater[x + 1, y + 1] == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Right
else if (AboveWater[x + 1, y] == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// LowerRight
else if (AboveWater[x + 1, y - 1] == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
else if (AboveWater[x + 2, y] == 1
|| AboveWater[x + 2, y - 1] == 1
|| AboveWater[x + 2, y + 1] == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
}
// Came from below
else if ((Y[z - 1] == Y[z] - 1) && (X[z - 1] == X[z]))
{
// Left
if (AboveWater[x - 1, y] == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top left
else if (AboveWater[x - 1, y + 1] == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top
else if (AboveWater[x, y + 1] == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top Right
else if (AboveWater[x + 1, y + 1] == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Right
else if (AboveWater[x + 1, y] == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Right
else if (AboveWater[x + 1, y - 1] == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Below
else if (AboveWater[x, y - 1] == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
}
// Came from bottom left
else if ((Y[z - 1] == Y[z] - 1) && (X[z - 1] == X[z] - 1))
{
// Top Left
if (AboveWater[x - 1, y + 1] == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top
else if (AboveWater[x, y + 1] == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top Right
else if (AboveWater[x + 1, y + 1] == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Right
else if (AboveWater[x + 1, y] == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Right
else if (AboveWater[x + 1, y - 1] == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom
else if (AboveWater[x, y - 1] == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Left
else if (AboveWater[x - 1, y - 1] == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
}
}
void FindNextTideCell_Jan23(int x, int y, int z)
{
// Function to find next cell that is beach moving in the general positive X direction
// changes global variables NextX and NextY, coordinates for the next beach cell
// This function will use but not affect the global arrays: AllBeach [][], X[], and Y[]
int a = 1; // if can't find where we came from, look + cell out again
int b = 1; // if we can't find the next cell, look another cell out
//int getOut_a = 0;
//while (getOut_a == 0 && Y[z - a] > 0 && X[z - a] > 0)
//{
// Came from left
if ((Y[z - a] == Y[z]) && (X[z - a] == X[z] - a))
{
int getOut = 0;
while (getOut == 0)
{
// Top
if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Right
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom
else if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
// Came from top left
else if ((Y[z - a] == Y[z] + a) && (X[z - a] == X[z] - a))
{
int getOut = 0;
while (getOut == 0)
{
// Top Right
if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Right
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom
else if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
// Came from above
else if ((Y[z - a] == Y[z] + a) && (X[z - a] == X[z]))
{
int getOut = 0;
while (getOut == 0)
{
// Right
if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Right
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom
else if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Above
else if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
// Came from upper right
else if ((Y[z - a] == Y[z] + a) && (X[z - a] == X[z] + a))
{
int getOut = 0;
while (getOut == 0)
{
// Bottom Right
if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom
else if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top
else if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Upper Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
// Came from right
else if ((Y[z - a] == Y[z]) && (X[z - a] == X[z] + a))
{
int getOut = 0;
while (getOut == 0)
{
// Bottom
if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top
else if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
return;
}
else
{
b++;
getOut = 0;
}
}
}
// Came from lower right
else if ((Y[z - a] == Y[z] - a) && (X[z - a] == X[z] + a))
{
int getOut = 0;
while (getOut == 0)
{
// Bottom left
if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top
else if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// LowerRight
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
//else if (AboveWater[x + 2, y] == 1
// || AboveWater[x + 2, y - 1] == 1
// || AboveWater[x + 2, y + 1] == 1)
//{
// NextX = x + 1;
// NextY = y;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
//}
else
{
b++;
getOut = 0;
}
}
}
// Came from below
else if ((Y[z - a] == Y[z] - a) && (X[z - a] == X[z]))
{
int getOut = 0;
while (getOut == 0)
{
// Left
if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top
else if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Right
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Below
else if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
// Came from bottom left
else if ((Y[z - a] == Y[z] - a) && (X[z - a] == X[z] - a))
{
int getOut = 0;
while (getOut == 0)
{
// Top Left
if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top
else if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Right
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom
else if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
//}
//else
//{
// a++;
// getOut_a = 0;
//}
}
else if (X[z - a] < X[z])
{
int getOut = 0;
while (getOut == 0 && (x + b < pbEnd - 1))
{
// Top
if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Right
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
else if (X[z - a] > X[z])
{
int getOut = 0;
while (getOut == 0 && (x - b > 0))
{
// Bottom
if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
}
void FindNextTideCell(int x, int y, int z)
{
// Function to find next cell that is beach moving in the general positive X direction
// changes global variables NextX and NextY, coordinates for the next beach cell
// This function will use but not affect the global arrays: AllBeach [][], X[], and Y[]
int a = 1; // if can't find where we came from, look + cell out again
int b = 1; // if we can't find the next cell, look another cell out
//int getOut_a = 0;
//while (getOut_a == 0 && Y[z - a] > 0 && X[z - a] > 0)
//{
// Came from left
if ((Y[z - a] == Y[z]) && (X[z - a] == X[z] - a))
{
int getOut = 0;
while (getOut == 0)
{
// Top
if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Right
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom
else if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
// Came from top left
else if ((Y[z - a] == Y[z] + a) && (X[z - a] == X[z] - a))
{
int getOut = 0;
while (getOut == 0)
{
// Top Right
if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Right
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom
else if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
// Came from above
else if ((Y[z - a] == Y[z] + a) && (X[z - a] == X[z]))
{
int getOut = 0;
while (getOut == 0)
{
// Right
if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Right
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom
else if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Above
else if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
// Came from upper right
else if ((Y[z - a] == Y[z] + a) && (X[z - a] == X[z] + a))
{
int getOut = 0;
while (getOut == 0)
{
// Bottom Right
if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom
else if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX - b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top
else if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Upper Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
// Came from right
else if ((Y[z - a] == Y[z]) && (X[z - a] == X[z] + a))
{
int getOut = 0;
while (getOut == 0)
{
// Bottom
if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top
else if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
return;
}
else
{
b++;
getOut = 0;
}
}
}
// Came from lower right
else if ((Y[z - a] == Y[z] - a) && (X[z - a] == X[z] + a))
{
int getOut = 0;
while (getOut == 0)
{
// Bottom left
if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top
else if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// LowerRight
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
//else if (AboveWater[x + 2, y] == 1
// || AboveWater[x + 2, y - 1] == 1
// || AboveWater[x + 2, y + 1] == 1)
//{
// NextX = x + 1;
// NextY = y;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
//}
else
{
b++;
getOut = 0;
}
}
}
// Came from below
else if ((Y[z - a] == Y[z] - a) && (X[z - a] == X[z]))
{
int getOut = 0;
while (getOut == 0)
{
// Left
if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top
else if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Right
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Below
else if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
// Came from bottom left
else if ((Y[z - a] == Y[z] - a) && (X[z - a] == X[z] - a))
{
int getOut = 0;
while (getOut == 0)
{
// Top Left
if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top
else if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Right
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom
else if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
//}
//else
//{
// a++;
// getOut_a = 0;
//}
}
else if (X[z - a] < X[z])
{
int getOut = 0;
while (getOut == 0 && (x + b < pbEnd - 1))
{
// Top
if (AboveWater[x, y + b] == 1)
{
NextX = x;
NextY = y + b;
BehindX = NextX + b;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Right
else if (AboveWater[x + b, y + b] == 1)
{
NextX = x + b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Right
else if (AboveWater[x + b, y] == 1)
{
NextX = x + b;
NextY = y;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom Right
else if (AboveWater[x + b, y - b] == 1)
{
NextX = x + b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY - b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
else if (X[z - a] > X[z])
{
int getOut = 0;
while (getOut == 0 && (x - b > 0))
{
// Bottom
if (AboveWater[x, y - b] == 1)
{
NextX = x;
NextY = y - b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Bottom left
else if (AboveWater[x - b, y - b] == 1)
{
NextX = x - b;
NextY = y - b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Left
else if (AboveWater[x - b, y] == 1)
{
NextX = x - b;
NextY = y;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
// Top Left
else if (AboveWater[x - b, y + b] == 1)
{
NextX = x - b;
NextY = y + b;
BehindX = NextX;
BehindY = NextY + b;
//BehindX = x;
//BehindY = y;
getOut = 1;
return;
}
else
{
b++;
getOut = 0;
}
}
}
}
// Find Shoreline cells - withOUT tides
void FindBeachCells(int XStart)
{
// Determines locations of beach cells moving from left to right direction
// This function will affect and determine the global arrays: X[] and Y[]
// This function calls FindNextCell
// This will define TotalBeachCells for this time step
int x, z, ystart;
ystart = ymax - 1;
x = XStart;
// Two while loops finding the start position of the beach (0) and second position (1)
//while (AllBeach[x, ystart] == 0)
while (AboveWater[x, ystart] == 0)
{
ystart -= 1;
}
// Step back to where partially full beach
//ystart += 1;
X[0] = XStart;
Y[0] = ystart;
//Need to give these some values for 'weathered rock'
XBehind[0] = X[0];
YBehind[0] = Y[0];
//while (AllBeach[x + 1, ystart] == 0)
while (AboveWater[x + 1, ystart] == 0)
{
ystart -= 1;
}
//ystart += 1;
X[1] = XStart + 1;
Y[1] = ystart;
XBehind[1] = X[0];
YBehind[1] = Y[0];
//XYFile.Write("Iteration: " + "Z: " + "X: " + "Y: " + Environment.NewLine);
//XYFile.Write(counter + " 0 " + X[0] + " " + Y[0] + Environment.NewLine
// + counter + " 1 " + X[1] + " " + Y[1] + Environment.NewLine);
z = 1;
while ((X[z] < pbEnd - 1) && (z < MaxBeachLength - 1))
{
z++;
NextX = -2;
NextY = -2;
BehindX = -2;
BehindY = -2;
FindNextCell(X[z - 1], Y[z - 1], z - 1);
X[z] = NextX;
Y[z] = NextY;
XBehind[z] = BehindX;
YBehind[z] = BehindY;
// If return to start point or go off left side of array, going the wrong direction
// Jump off and start again closer to middle
//Print to file X[] and Y[] Arrays
//XYFile.Write(counter + " " + z + " " + X[z] + " " + Y[z] + Environment.NewLine);
if ((NextX < 1) || ((NextX == X[0]) && (NextY == Y[0])) || (z > MaxBeachLength - 2))
{
FellOffArray = 'y';
ZeroVars();
return;
}
}
TotalBeachCells = z;
FellOffArray = 'n';
//XYFile.Close();
}
//void FindNextCell(int x, int y, int z)
//{
// // Function to find next cell that is beach moving in the general positive X direction
// // changes global variables NextX and NextY, coordinates for the next beach cell
// // This function will use but not affect the global arrays: AllBeach [][], X[], and Y[]
// // Came from left
// if ((Y[z - 1] == Y[z]) && (X[z - 1] == X[z] - 1))
// {
// // Top
// if ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) > 0.0)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Right
// else if ((PercentFullSand[x + 1, y + 1] + PercentFullRock[x + 1, y + 1]) > 0.0)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Right
// else if ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) > 0.0)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Right
// else if ((PercentFullSand[x + 1, y - 1] + PercentFullRock[x + 1, y - 1]) > 0.0)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom
// else if ((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) > 0.0)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Left
// else if ((PercentFullSand[x - 1, y - 1] + PercentFullRock[x - 1, y - 1]) > 0.0)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// //// Left
// //else if ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) > 0.0)
// //{
// // NextX = x - 1;
// // NextY = y;
// // BehindX = NextX;
// // BehindY = NextY - 1;
// // //BehindX = x;
// // //BehindY = y;
// // return;
// //}
// }
// // Came from top left
// else if ((Y[z - 1] == Y[z] + 1) && (X[z - 1] == X[z] - 1))
// {
// // Top Right
// if ((PercentFullSand[x + 1, y + 1] + PercentFullRock[x + 1, y + 1]) > 0.0)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Right
// else if ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) > 0.0)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Right
// else if ((PercentFullSand[x + 1, y - 1] + PercentFullRock[x + 1, y - 1]) > 0.0)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom
// else if ((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) > 0.0)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Left
// else if ((PercentFullSand[x - 1, y - 1] + PercentFullRock[x - 1, y - 1]) > 0.0)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Left
// else if ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) > 0.0)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// //// Top Left
// //else if ((PercentFullSand[x - 1, y + 1] + PercentFullRock[x - 1, y + 1]) > 0.0)
// //{
// // NextX = x - 1;
// // NextY = y + 1;
// // BehindX = NextX - 1;
// // BehindY = NextY;
// // //BehindX = x;
// // //BehindY = y;
// // return;
// //}
// }
// // Came from above
// else if ((Y[z - 1] == Y[z] + 1) && (X[z - 1] == X[z]))
// {
// // Right
// if ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) > 0.0)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Right
// else if ((PercentFullSand[x + 1, y - 1] + PercentFullRock[x + 1, y - 1]) > 0.0)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom
// else if ((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) > 0.0)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Left
// else if ((PercentFullSand[x - 1, y - 1] + PercentFullRock[x - 1, y - 1]) > 0.0)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Left
// else if ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) > 0.0)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top left
// else if ((PercentFullSand[x - 1, y + 1] + PercentFullRock[x - 1, y + 1]) > 0.0)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// //// Top
// //else if ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) > 0.0)
// //{
// // NextX = x;
// // NextY = y + 1;
// // BehindX = NextX - 1;
// // BehindY = NextY;
// // //BehindX = x;
// // //BehindY = y;
// // return;
// //}
// }
// // Came from upper right
// else if ((Y[z - 1] == Y[z] + 1) && (X[z - 1] == X[z] + 1))
// {
// // Bottom Right
// if ((PercentFullSand[x + 1, y - 1] + PercentFullRock[x + 1, y - 1]) > 0.0)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom
// else if ((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) > 0.0)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom left
// else if ((PercentFullSand[x - 1, y - 1] + PercentFullRock[x - 1, y - 1]) > 0.0)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Left
// else if ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) > 0.0)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Left
// else if ((PercentFullSand[x - 1, y + 1] + PercentFullRock[x - 1, y + 1]) > 0.0)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top
// else if ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) > 0.0)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// //// Right
// //else if ((PercentFullSand[x + 1, y + 1] + PercentFullRock[x + 1, y + 1]) > 0.0)
// //{
// // NextX = x + 1;
// // NextY = y + 1;
// // BehindX = NextX;
// // BehindY = NextY + 1;
// // //BehindX = x;
// // //BehindY = y;
// // return;
// //}
// }
// // Came from right
// else if ((Y[z - 1] == Y[z]) && (X[z - 1] == X[z] + 1))
// {
// // Bottom
// if ((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) > 0.0)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom left
// else if ((PercentFullSand[x - 1, y - 1] + PercentFullRock[x - 1, y - 1]) > 0.0)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Left
// else if ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) > 0.0)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Left
// else if ((PercentFullSand[x - 1, y + 1] + PercentFullRock[x - 1, y + 1]) > 0.0)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top
// else if ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) > 0.0)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Right
// else if ((PercentFullSand[x + 1, y + 1] + PercentFullRock[x + 1, y + 1]) > 0.0)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// //// Right
// //else if ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) > 0.0)
// //{
// // NextX = x + 1;
// // NextY = y;
// // BehindX = NextX;
// // BehindY = NextY + 1;
// // //BehindX = x;
// // //BehindY = y;
// // return;
// //}
// }
// // Came from lower right
// else if ((Y[z - 1] == Y[z] - 1) && (X[z - 1] == X[z] + 1))
// {
// // Bottom left
// if ((PercentFullSand[x - 1, y - 1] + PercentFullRock[x - 1, y - 1]) > 0.0)
// {
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Left
// else if ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) > 0.0)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Left
// else if ((PercentFullSand[x - 1, y + 1] + PercentFullRock[x - 1, y + 1]) > 0.0)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top
// else if ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) > 0.0)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Right
// else if ((PercentFullSand[x + 1, y + 1] + PercentFullRock[x + 1, y + 1]) > 0.0)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Right
// else if ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) > 0.0)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// else if (PercentFullSand[x + 2, y] + PercentFullRock[x + 2, y] > 0.0
// || PercentFullSand[x + 2, y - 1] + PercentFullRock[x + 2, y - 1] > 0.0
// || PercentFullSand[x + 2, y + 1] + PercentFullRock[x + 2, y + 1] > 0.0)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// //// Bottom Right
// //else if ((PercentFullSand[x + 1, y - 1] + PercentFullRock[x + 1, y - 1]) > 0.0)
// //{
// // NextX = x + 1;
// // NextY = y - 1;
// // BehindX = NextX + 1;
// // BehindY = NextY;
// // //BehindX = x;
// // //BehindY = y;
// // return;
// //}
// }
// // Came from below
// else if ((Y[z - 1] == Y[z] - 1) && (X[z - 1] == X[z]))
// {
// // Left
// if ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) > 0.0)
// {
// NextX = x - 1;
// NextY = y;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top left
// else if ((PercentFullSand[x - 1, y + 1] + PercentFullRock[x - 1, y + 1]) > 0.0)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top
// else if ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) > 0.0)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Right
// else if ((PercentFullSand[x + 1, y + 1] + PercentFullRock[x + 1, y + 1]) > 0.0)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Right
// else if ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) > 0.0)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Right
// else if ((PercentFullSand[x + 1, y - 1]) + PercentFullRock[x + 1, y - 1] > 0.0)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// //// Below
// //else if ((PercentFullSand[x, y - 1]) + PercentFullRock[x, y - 1] > 0.0)
// //{
// // NextX = x;
// // NextY = y - 1;
// // BehindX = NextX;
// // BehindY = NextY - 1;
// // //BehindX = x;
// // //BehindY = y;
// // return;
// //}
// }
// // Came from bottom left
// else if ((Y[z - 1] == Y[z] - 1) && (X[z - 1] == X[z] - 1))
// {
// // Top Left
// if ((PercentFullSand[x - 1, y + 1] + PercentFullRock[x - 1, y + 1]) > 0.0)
// {
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top
// else if ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) > 0.0)
// {
// NextX = x;
// NextY = y + 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Top Right
// else if ((PercentFullSand[x + 1, y + 1] + PercentFullRock[x + 1, y + 1]) > 0.0)
// {
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Right
// else if ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) > 0.0)
// {
// NextX = x + 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom Right
// else if ((PercentFullSand[x + 1, y - 1] + PercentFullRock[x + 1, y - 1]) > 0.0)
// {
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// // Bottom
// else if ((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) > 0.0)
// {
// NextX = x;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
// }
// //// Bottom Left
// //else if ((PercentFullSand[x - 1, y - 1] + PercentFullRock[x - 1, y - 1]) > 0.0)
// //{
// // NextX = x - 1;
// // NextY = y - 1;
// // BehindX = NextX;
// // BehindY = NextY - 1;
// // //BehindX = x;
// // //BehindY = y;
// // return;
// //}
// }
//}
// Rock Calculations (weathering)
void FindNextCell(int x, int y, int z)
{
// Function to find next cell that is beach moving in the general positive X direction
// changes global variables NextX and NextY, coordinates for the next beach cell
// This function will use but not affect the global arrays: AllBeach [][], X[], and Y[]
// Came from left
if ((Y[z - 1] == Y[z]) && (X[z - 1] == X[z] - 1))
{
// Top
if ((AboveWater[x, y + 1]) == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top Right
else if ((AboveWater[x + 1, y + 1]) == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Right
else if ((AboveWater[x + 1, y]) == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Right
else if ((AboveWater[x + 1, y - 1]) == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom
else if ((AboveWater[x, y - 1]) == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Left
else if ((AboveWater[x - 1, y - 1]) == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
//// Left
//else if ((Elevation[x - 1, y] + PercentFullRock[x - 1, y]) > 0.0)
//{
// NextX = x - 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
//}
}
// Came from top left
else if ((Y[z - 1] == Y[z] + 1) && (X[z - 1] == X[z] - 1))
{
// Top Right
if ((AboveWater[x + 1, y + 1]) == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Right
else if ((AboveWater[x + 1, y]) == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Right
else if ((AboveWater[x + 1, y - 1]) == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom
else if ((AboveWater[x, y - 1]) == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Left
else if ((AboveWater[x - 1, y - 1]) == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Left
else if ((AboveWater[x - 1, y]) == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
//// Top Left
//else if ((Elevation[x - 1, y + 1] + PercentFullRock[x - 1, y + 1]) > 0.0)
//{
// NextX = x - 1;
// NextY = y + 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
//}
}
// Came from above
else if ((Y[z - 1] == Y[z] + 1) && (X[z - 1] == X[z]))
{
// Right
if ((AboveWater[x + 1, y]) == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Right
else if ((AboveWater[x + 1, y - 1]) == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom
else if ((AboveWater[x, y - 1]) == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Left
else if ((AboveWater[x - 1, y - 1]) == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Left
else if ((AboveWater[x - 1, y]) == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top left
else if ((AboveWater[x - 1, y + 1]) == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
//// Top
//else if ((Elevation[x, y + 1] + PercentFullRock[x, y + 1]) > 0.0)
//{
// NextX = x;
// NextY = y + 1;
// BehindX = NextX - 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
//}
}
// Came from upper right
else if ((Y[z - 1] == Y[z] + 1) && (X[z - 1] == X[z] + 1))
{
// Bottom Right
if ((AboveWater[x + 1, y - 1]) == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom
else if ((AboveWater[x, y - 1]) == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX - 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom left
else if ((AboveWater[x - 1, y - 1]) == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Left
else if ((AboveWater[x - 1, y]) == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top Left
else if ((AboveWater[x - 1, y + 1]) == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top
else if ((AboveWater[x, y + 1]) == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
//// Right
//else if ((Elevation[x + 1, y + 1] + PercentFullRock[x + 1, y + 1]) > 0.0)
//{
// NextX = x + 1;
// NextY = y + 1;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
//}
}
// Came from right
else if ((Y[z - 1] == Y[z]) && (X[z - 1] == X[z] + 1))
{
// Bottom
if ((AboveWater[x, y - 1]) == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom left
else if ((AboveWater[x - 1, y - 1]) == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Left
else if ((AboveWater[x - 1, y]) == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top Left
else if ((AboveWater[x - 1, y + 1]) == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top
else if ((AboveWater[x, y + 1]) == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top Right
else if ((AboveWater[x + 1, y + 1]) == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
//// Right
//else if ((Elevation[x + 1, y] + PercentFullRock[x + 1, y]) > 0.0)
//{
// NextX = x + 1;
// NextY = y;
// BehindX = NextX;
// BehindY = NextY + 1;
// //BehindX = x;
// //BehindY = y;
// return;
//}
}
// Came from lower right
else if ((Y[z - 1] == Y[z] - 1) && (X[z - 1] == X[z] + 1))
{
// Bottom left
if ((AboveWater[x - 1, y - 1]) == 1)
{
NextX = x - 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Left
else if ((AboveWater[x - 1, y]) == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top Left
else if ((AboveWater[x - 1, y + 1]) == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY + 1;
//BehindX = x;
//BehindY = y;
return;
}
// Top
else if ((AboveWater[x, y + 1]) == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top Right
else if ((AboveWater[x + 1, y + 1]) == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Right
else if ((AboveWater[x + 1, y]) == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
else if (AboveWater[x + 2, y] == 1
|| AboveWater[x + 2, y - 1] == 1
|| AboveWater[x + 2, y + 1] == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
//// Bottom Right
//else if ((Elevation[x + 1, y - 1] + PercentFullRock[x + 1, y - 1]) > 0.0)
//{
// NextX = x + 1;
// NextY = y - 1;
// BehindX = NextX + 1;
// BehindY = NextY;
// //BehindX = x;
// //BehindY = y;
// return;
//}
}
// Came from below
else if ((Y[z - 1] == Y[z] - 1) && (X[z - 1] == X[z]))
{
// Left
if ((AboveWater[x - 1, y]) == 1)
{
NextX = x - 1;
NextY = y;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top left
else if ((AboveWater[x - 1, y + 1]) == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top
else if ((AboveWater[x, y + 1] ) == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top Right
else if ((AboveWater[x + 1, y + 1]) == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Right
else if ((AboveWater[x + 1, y]) == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Right
else if ((AboveWater[x + 1, y - 1]) == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
//// Below
//else if ((Elevation[x, y - 1]) + PercentFullRock[x, y - 1] > 0.0)
//{
// NextX = x;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
//}
}
// Came from bottom left
else if ((Y[z - 1] == Y[z] - 1) && (X[z - 1] == X[z] - 1))
{
// Top Left
if ((AboveWater[x - 1, y + 1]) == 1)
{
NextX = x - 1;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top
else if ((AboveWater[x, y + 1]) == 1)
{
NextX = x;
NextY = y + 1;
BehindX = NextX + 1;
BehindY = NextY;
//BehindX = x;
//BehindY = y;
return;
}
// Top Right
else if ((AboveWater[x + 1, y + 1]) == 1)
{
NextX = x + 1;
NextY = y + 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Right
else if ((AboveWater[x + 1, y]) == 1)
{
NextX = x + 1;
NextY = y;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom Right
else if ((AboveWater[x + 1, y - 1]) == 1)
{
NextX = x + 1;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
// Bottom
else if ((AboveWater[x, y - 1]) == 1)
{
NextX = x;
NextY = y - 1;
BehindX = NextX;
BehindY = NextY - 1;
//BehindX = x;
//BehindY = y;
return;
}
//// Bottom Left
//else if ((Elevation[x - 1, y - 1] + PercentFullRock[x - 1, y - 1]) > 0.0)
//{
// NextX = x - 1;
// NextY = y - 1;
// BehindX = NextX;
// BehindY = NextY - 1;
// //BehindX = x;
// //BehindY = y;
// return;
//}
}
}
void FindRockCells(int XStart)
{
//LMV
//Determines locations of rock cells moving from left to right direction
//This function will affect and determine the global arrays: XRock[] and YRock[]
//This function calls FindNextRockCell
//This will define TotalRockCells for this time step
int x, z, ystart;
//StreamWriter XYRockFile = new StreamWriter("TEST_FILES/XYRock.dat");
// Starting at left end, find the x - value for first cell that is 'allbeach'
ystart = ymax - 1;
x = XStart;
// Two while loops finding the start position of the Rock (0) and second position (1)
while (AllRock[x, ystart] == 0)
{
ystart -= 1;
}
// Step back to where partially full beach
ystart += 1;
YRock[0] = ystart;
XRock[0] = XStart;
//Need to give these some values for 'weathered rock'
XRockBehind[0] = XRock[0];
YRockBehind[0] = YRock[0];
while (AllRock[x + 1, ystart] == 0)
{
ystart -= 1;
}
ystart += 1;
YRock[1] = ystart;
XRock[1] = XStart + 1;
XRockBehind[1] = XRock[0];
YRockBehind[1] = YRock[0];
// XYRockFile.Write("Iteration: " + "Z: " + "X: " + "Y: " + Environment.NewLine);
// XYRockFile.Write(counter + " 0 " + XRock[0] + " " + YRock[0] + Environment.NewLine
// + counter + " 1 " + XRock[1] + " " + YRock[1] + Environment.NewLine);
z = 1;
while ((XRock[z] < pbEnd - 1) && (z < MaxBeachLength - 1))
{
z++;
NextRockX = -2;
NextRockY = -2;
BehindRockX = -2;
BehindRockY = -2;
FindNextRockCell(XRock[z - 1], YRock[z - 1], z - 1);
XRock[z] = NextRockX;
YRock[z] = NextRockY;
XRockBehind[z] = BehindRockX;
YRockBehind[z] = BehindRockY;
//Print to file XRock[] and YRock[] Arrays
// XYRockFile.Write(counter + " " + z + " " + XRock[z] + " " + YRock[z] + Environment.NewLine);
// If return to start point or go off left side of array, going the wrong direction
// Jump off and start again closer to middle
if ((NextRockX < 1) || ((NextRockX == XRock[0]) && (NextRockY == YRock[0])) || (z > MaxBeachLength - 2))
{
FellOffRockArray = 'y';
ZeroVars();
return;
}
}
TotalRockCells = z;
FellOffRockArray = 'n';
//XYRockFile.Close();
}
//void FindNextRockCell(int x, int y, int z)
//{
// // Function to find next cell that is rock moving in the general positive X direction
// // changes global variables NextRockX and NextRockY, coordinates for the next beach cell
// // This function will use but not affect the global arrays: AllRock [][], XRock[], and YRock[]
// // Came from left
// if ((YRock[z - 1] == YRock[z]) && (XRock[z - 1] == XRock[z] - 1))
// {
// if (PercentFullRock[x, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x + 1;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y] > 0.0)
// {
// NextRockY = y;
// NextRockX = x + 1;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x + 1;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x - 1;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// }
// // Came from upper left
// else if ((YRock[z - 1] == YRock[z] + 1) && (XRock[z - 1] == XRock[z] - 1))
// {
// if (PercentFullRock[x + 1, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x + 1;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y] > 0.0)
// {
// NextRockY = y;
// NextRockX = x + 1;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x + 1;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX - 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x - 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX - 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y] > 0.0)
// {
// NextRockY = y;
// NextRockX = x - 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX - 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// }
// // Came from above
// else if ((YRock[z - 1] == YRock[z] + 1) && (XRock[z - 1] == XRock[z]))
// {
// if (PercentFullRock[x + 1, y] > 0.0)
// {
// NextRockY = y;
// NextRockX = x + 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX - 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x + 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX - 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX - 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x - 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX - 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y] > 0.0)
// {
// NextRockY = y;
// NextRockX = x - 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX - 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x - 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX - 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// }
// // Came from upper right
// else if ((YRock[z - 1] == YRock[z] + 1) && (XRock[z - 1] == XRock[z] + 1))
// {
// if (PercentFullRock[x + 1, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x + 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX - 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX - 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x - 1;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y] > 0.0)
// {
// NextRockY = y;
// NextRockX = x - 1;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x - 1;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// }
// // Came from right
// else if ((YRock[z - 1] == YRock[z]) && (XRock[z - 1] == XRock[z] + 1))
// {
// if (PercentFullRock[x, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x - 1;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y] > 0.0)
// {
// NextRockY = y;
// NextRockX = x - 1;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x - 1;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x + 1;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// }
// // Came from lower right
// else if ((XRock[z - 1] == XRock[z] - 1) && (YRock[z - 1] == YRock[z] + 1))
// {
// if (PercentFullRock[x - 1, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x - 1;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y] > 0.0)
// {
// NextRockY = y;
// NextRockX = x - 1;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x - 1;
// //BehindRockY = NextRockY + 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX + 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x + 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX + 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y] > 0.0)
// {
// NextRockY = y;
// NextRockX = x + 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX + 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// }
// // Came from below
// else if ((YRock[z - 1] == YRock[z] - 1) && (XRock[z - 1] == XRock[z]))
// {
// if (PercentFullRock[x - 1, y] > 0.0)
// {
// NextRockY = y;
// NextRockX = x - 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX + 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x - 1, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x - 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX + 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX + 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x + 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX + 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y] > 0.0)
// {
// NextRockY = y;
// NextRockX = x + 1;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x + 1;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// }
// // Came from lower left
// else if ((YRock[z - 1] == YRock[z] - 1) && (XRock[z - 1] == XRock[z] - 1))
// {
// if (PercentFullRock[x - 1, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x - 1;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX + 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x;
// //BehindRockY = NextRockY;
// //BehindRockX = NextRockX + 1;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y + 1] > 0.0)
// {
// NextRockY = y + 1;
// NextRockX = x + 1;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y] > 0.0)
// {
// NextRockY = y;
// NextRockX = x + 1;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x + 1, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x + 1;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// else if (PercentFullRock[x, y - 1] > 0.0)
// {
// NextRockY = y - 1;
// NextRockX = x;
// //BehindRockY = NextRockY - 1;
// //BehindRockX = NextRockX;
// BehindRockX = x;
// BehindRockY = y;
// return;
// }
// }
//}
void FindNextRockCell(int x, int y, int z)
{
// Function to find next cell that is rock moving in the general positive X direction
// changes global variables NextRockX and NextRockY, coordinates for the next beach cell
// This function will use but not affect the global arrays: AllRock [][], XRock[], and YRock[]
// Came from left
if ((YRock[z - 1] == YRock[z]) && (XRock[z - 1] == XRock[z] - 1))
{
if (PercentFullRock[x, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x + 1;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y] > 0.0)
{
NextRockY = y;
NextRockX = x + 1;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x + 1;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x - 1;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
}
// Came from upper left
else if ((YRock[z - 1] == YRock[z] + 1) && (XRock[z - 1] == XRock[z] - 1))
{
if (PercentFullRock[x + 1, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x + 1;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y] > 0.0)
{
NextRockY = y;
NextRockX = x + 1;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x + 1;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x;
BehindRockY = NextRockY;
BehindRockX = NextRockX - 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x - 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX - 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y] > 0.0)
{
NextRockY = y;
NextRockX = x - 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX - 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
}
// Came from above
else if ((YRock[z - 1] == YRock[z] + 1) && (XRock[z - 1] == XRock[z]))
{
if (PercentFullRock[x + 1, y] > 0.0)
{
NextRockY = y;
NextRockX = x + 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX - 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x + 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX - 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x;
BehindRockY = NextRockY;
BehindRockX = NextRockX - 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x - 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX - 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y] > 0.0)
{
NextRockY = y;
NextRockX = x - 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX - 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x - 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX - 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
}
// Came from upper right
else if ((YRock[z - 1] == YRock[z] + 1) && (XRock[z - 1] == XRock[z] + 1))
{
if (PercentFullRock[x + 1, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x + 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX - 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x;
BehindRockY = NextRockY;
BehindRockX = NextRockX - 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x - 1;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y] > 0.0)
{
NextRockY = y;
NextRockX = x - 1;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x - 1;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
}
// Came from right
else if ((YRock[z - 1] == YRock[z]) && (XRock[z - 1] == XRock[z] + 1))
{
if (PercentFullRock[x, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x - 1;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y] > 0.0)
{
NextRockY = y;
NextRockX = x - 1;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x - 1;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x + 1;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
}
// Came from lower right
else if ((XRock[z - 1] == XRock[z] - 1) && (YRock[z - 1] == YRock[z] + 1))
{
if (PercentFullRock[x - 1, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x - 1;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y] > 0.0)
{
NextRockY = y;
NextRockX = x - 1;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x - 1;
BehindRockY = NextRockY + 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x;
BehindRockY = NextRockY;
BehindRockX = NextRockX + 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x + 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX + 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y] > 0.0)
{
NextRockY = y;
NextRockX = x + 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX + 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
}
// Came from below
else if ((YRock[z - 1] == YRock[z] - 1) && (XRock[z - 1] == XRock[z]))
{
if (PercentFullRock[x - 1, y] > 0.0)
{
NextRockY = y;
NextRockX = x - 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX + 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x - 1, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x - 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX + 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x;
BehindRockY = NextRockY;
BehindRockX = NextRockX + 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x + 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX + 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y] > 0.0)
{
NextRockY = y;
NextRockX = x + 1;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x + 1;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
}
// Came from lower left
else if ((YRock[z - 1] == YRock[z] - 1) && (XRock[z - 1] == XRock[z] - 1))
{
if (PercentFullRock[x - 1, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x - 1;
BehindRockY = NextRockY;
BehindRockX = NextRockX + 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x;
BehindRockY = NextRockY;
BehindRockX = NextRockX + 1;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y + 1] > 0.0)
{
NextRockY = y + 1;
NextRockX = x + 1;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y] > 0.0)
{
NextRockY = y;
NextRockX = x + 1;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x + 1, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x + 1;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
else if (PercentFullRock[x, y - 1] > 0.0)
{
NextRockY = y - 1;
NextRockX = x;
BehindRockY = NextRockY - 1;
BehindRockX = NextRockX;
//BehindRockX = x;
//BehindRockY = y;
return;
}
}
}
void RockCalculations()
{
// For each Rock cell j, moves along the beach and determines distance from rock to beach and amount of rock to weather
// This function calls FindNearestBeach and WeatherRock
// This function will use but not adjust the variable TotalRockCells
// Determines the total amount of rock weathered in one time step
int j;
double TotalAmountWeathered = 0.0;
CurrentPercentFine = 0;
for (j = 0; j <= TotalRockCells; j++)
{
FindNearestBeach(j);
WeatherRock(j);
TotalAmountWeathered += AmountWeathered[j];
if (TypeOfRock[XRock[j], YRock[j]] == 'f')
{
CurrentPercentFine = PercentFineFast;
}
else if (TypeOfRock[XRock[j], YRock[j]] == 's')
{
CurrentPercentFine = PercentFineSlow;
}
else
{
MessageBox.Show("Problem with 'Rock Calculation' - CurrentPercentFine");
}
if (AmountWeathered[j] > 0.0 && CurrentPercentFine > 0.0)
{
RemoveFines(j, (CurrentPercentFine * AmountWeathered[j]));
}
}
}
void FindNearestBeach(int j)
{
// Calculates the Euclidean distance between Rock and Beach for entire beach array
// Finds the minimum beach to rock distance
// This function will use but not adjust the global arrays: X[], Y[], XRock[], YRock[], PercentFullSand[][]
// This function will use but not adjust the variables MinDistanceToBeach and TotalBeachCells
int i;
double DeltaX, DeltaY;
int LookStart, LookEnd;
MinDistanceToBeach[j] = BigDistanceToBeach;
// Do a full sweep every now and then
if (counter % TimeToSweepFullBeach == 0)
{
for (i = 0; i <= TotalBeachCells; i++)
{
// Vertical Distance
if (Y[i] != YRock[j])
{
//Saying that all cells will be max cell width, so can just take PFS out of this equation
//DeltaY = ((Y[i] - YRock[j] - 1) + (PercentFullSand[X[i], Y[i]] + PercentFullSand[XRock[j], YRock[j]])) * CellWidth;
DeltaY = (Y[i] - YRock[j] - 1) * CellWidth;
}
else
{
//DeltaY = ((PercentFullSand[X[i], Y[i]]) * CellWidth);
DeltaY = CellWidth;
}
// Horizontal Distance
if (XRock[j] <= X[i])
{
DeltaX = (X[i] - XRock[j]) * CellWidth;
}
else
{
DeltaX = (XRock[j] - X[i]) * CellWidth;
}
DistanceToBeach[j] = Math.Sqrt((DeltaX * DeltaX) + (DeltaY * DeltaY));
if (DistanceToBeach[j] < MinDistanceToBeach[j])
{
MinDistanceToBeach[j] = DistanceToBeach[j];
ClosestBeach[j] = i;
}
}
}
else
// LookDist allows the program to skip the full beach sweep at every iteration by looking at
// the location of the previous closest beach and sweeping out a small arc plus or minus LookDist
{
if (ClosestBeach[j] - LookDist >= 0)
{
LookStart = ClosestBeach[j] - LookDist;
}
// Only sweep right when on left end
else
{
LookStart = 0;
}
if (ClosestBeach[j] + LookDist <= TotalBeachCells)
{
LookEnd = ClosestBeach[j] + LookDist;
}
// Only sweep left when at right end
else
{
LookEnd = TotalBeachCells;
}
for (i = LookStart; i < LookEnd; i++)
{
if (Y[i] != YRock[j])
{
//DeltaY = ((Y[i] - YRock[j] - 1) + (PercentFullSand[X[i], Y[i]] + PercentFullSand[XRock[j], YRock[j]])) * CellWidth;
DeltaY = (Y[i] - YRock[j] - 1) * CellWidth;
}
else
{
//DeltaY = (PercentFullSand[X[i], Y[i]]) * CellWidth;
DeltaY = CellWidth;
}
// Horizontal distance
if (XRock[j] <= X[i])
{
DeltaX = (X[i] - XRock[j]) * CellWidth;
}
else
{
DeltaX = (XRock[j] - X[i]) * CellWidth;
}
DistanceToBeach[j] = Math.Sqrt(DeltaY * DeltaY + DeltaX * DeltaX);
if (DistanceToBeach[j] < MinDistanceToBeach[j])
{
MinDistanceToBeach[j] = DistanceToBeach[j];
ClosestBeach[j] = i;
}
}
}
}
void WeatherRock(int j)
{
// With Cliffs
// Fuction changes PercentFullRock[][] and PercentFullSand[][] along the rock beach interface only
// At this point, weathering rate is pretty arbitrary
// Fuction also changes AllRock[][]
// Weathering rate changes along the shore, 'f' = fast weather, 's' = slow weathering
// Function uses (but does not change) TypeOfRock[][] to determine rate
double WeatheringRatePerYear;
// Slow rock weathering
if (TypeOfRock[XRock[j], YRock[j]] == 's')
{
// Think in terms of Vertical Equivalence
if ((MinDistanceToBeach[j] / CellWidth) <= NoWeathering)
{
// Exponential weathering based on sed cover
WeatheringRatePerYear = SlowWeatherCoeff * (Math.Exp((-MinDistanceToBeach[j]) / CellWidth));
}
else
{
WeatheringRatePerYear = 0;
}
}
// Fast rock weathering
else if (TypeOfRock[XRock[j], YRock[j]] == 'f')
{
// Think in terms of vertical equivalence
if ((MinDistanceToBeach[j] / CellWidth) <= NoWeathering)
{
//Exponential weathering based on sed cover
WeatheringRatePerYear = FastWeatherCoeff * (Math.Exp((-MinDistanceToBeach[j]) / CellWidth));
}
else
{
WeatheringRatePerYear = 0;
}
}
else
{
WeatheringRatePerYear = 0;
}
// Amount weathering per time step (Percent weathered which correlates with TimeStepValue)
AmountWeathered[j] = ((WeatheringRatePerYear * TimeStepValue) / 365) / CellWidth;
if (PercentFullRock[XRock[j], YRock[j]] >= AmountWeathered[j])
{
PercentFullRock[XRock[j], YRock[j]] -= AmountWeathered[j];
//Include cliff height
//PercentFullSand[XRock[j], YRock[j]] += AmountWeathered[j] + (AmountWeathered[j] *(CliffHeight/DepthShoreface)*(1-PercentFineFast));
PercentFullSand[XRock[j], YRock[j]] += AmountWeathered[j] + (AmountWeathered[j] * (CliffHeight / DepthShoreface) * (1 - PercentFineFast));
if (PercentFullRock[XRock[j], YRock[j]] < MaxFillCell)
{
AllRock[XRock[j], YRock[j]] = 0;
}
}
else if (PercentFullRock[XRock[j], YRock[j]] < AmountWeathered[j])
{
if ((PercentFullRock[XRock[j], YRock[j]] + PercentFullRock[XRockBehind[j], YRockBehind[j]]) >= AmountWeathered[j])
{
AllRock[XRockBehind[j], YRockBehind[j]] = 0;
PercentFullRock[XRockBehind[j], YRockBehind[j]] -= (AmountWeathered[j] - PercentFullRock[XRock[j], YRock[j]]);
PercentFullSand[XRockBehind[j], YRockBehind[j]] += (AmountWeathered[j] - PercentFullRock[XRock[j], YRock[j]] + ((AmountWeathered[j] - PercentFullRock[XRock[j], YRock[j]]) * (CliffHeight / DepthShoreface) * (1 - CurrentPercentFine)));
PercentFullSand[XRock[j], YRock[j]] += PercentFullRock[XRock[j], YRock[j]] + (PercentFullRock[XRock[j], YRock[j]] * (CliffHeight / DepthShoreface) * (1 - CurrentPercentFine));
PercentFullRock[XRock[j], YRock[j]] = 0.0;
}
else
{
PauseRun(-1, -1, j);
PercentFullSand[XRock[j], YRock[j]] += PercentFullRock[XRock[j], YRock[j]];
PercentFullRock[XRock[j], YRock[j]] = 0.0;
}
}
if (PercentFullSand[XRock[j], YRock[j]] < 0.0)
{
PercentFullSand[XRock[j], YRock[j]] = 0.0;
}
// After weathering, lose a percentage of weathered rock in the closest beach cell
// This represents fine grained material that does not stay in nearshore system
if ((AmountWeathered[j] > 0.0) && (TypeOfRock[XRock[j], YRock[j]] == 'f'))
{
PercentFullSand[X[ClosestBeach[j]], Y[ClosestBeach[j]]] -= PercentFineFast * AmountWeathered[j];
}
if ((AmountWeathered[j] > 0.0) && (TypeOfRock[XRock[j], YRock[j]] == 's'))
{
PercentFullSand[X[ClosestBeach[j]], Y[ClosestBeach[j]]] -= PercentFineSlow * AmountWeathered[j];
}
}
void RemoveFines(int j, double Fines)
{
//// After weathering, lose a percentage of weathered rock in the closest beach cell
//// This represents fine grained material that does not stay in nearshore system
//// Note, if closest beach cell doesn't have enough, take from cell behind.
//// if both don't have enough, take from the cells in which you created sed earlier.
//// those don't have enough, just empty them
//int takefrom;
//double Available;
////Fines from Percentage to volume
//Fines = Fines * CellWidth * TElevationCS[X[j], Y[j]];
//if (ClosestBeach[j] > 0 && ClosestBeach[j] < pbEnd && ClosestBeach[j] > 0 && ClosestBeach[j] < ymax)
//{
// if (Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]]] >= Fines)
// {
// Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]]] -= Fines;
// if ((Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]]]) > WaterLevel)
// {
// AboveWater[X[ClosestBeach[j]], Y[ClosestBeach[j]]] = 1;
// }
// else
// {
// AboveWater[X[ClosestBeach[j]], Y[ClosestBeach[j]]] = 0;
// }
// }
// else if (Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]]] + Volume[XBehind[ClosestBeach[j]], YBehind[ClosestBeach[j]]] >= Fines)
// {
// Volume[XBehind[ClosestBeach[j]], YBehind[ClosestBeach[j]]] -= (Fines - Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]]]);
// Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]]] = 0;
// if ((Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]]]) > WaterLevel)
// {
// AboveWater[X[ClosestBeach[j]], Y[ClosestBeach[j]]] = 1;
// }
// else
// {
// AboveWater[X[ClosestBeach[j]], Y[ClosestBeach[j]]] = 0;
// }
// if ((Volume[XBehind[ClosestBeach[j]], YBehind[ClosestBeach[j]]]) > WaterLevel)
// {
// AboveWater[XBehind[ClosestBeach[j]], YBehind[ClosestBeach[j]]] = 1;
// }
// else
// {
// AboveWater[XBehind[ClosestBeach[j]], YBehind[ClosestBeach[j]]] = 0;
// }
// }
// // Try to find enough...
// else if (Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]] + 1]
// + Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]] + 1]
// + Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]] + 1]
// + Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]]]
// + Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]]]
// + Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]] - 1]
// + Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]] - 1]
// + Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]] - 1]
// >= 0)
// {
// Available = Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]]]
// + Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]] + 1]
// + Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]] + 1]
// + Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]] + 1]
// + Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]]]
// + Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]]]
// + Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]] - 1]
// + Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]] - 1]
// + Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]] - 1];
// if (Available > Fines)
// {
// Available = Fines;
// }
// takefrom = 0;
// if (Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]] + 1] > 0) takefrom++;
// if (Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]] + 1] > 0) takefrom++;
// if (Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]] + 1] > 0) takefrom++;
// if (Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]]] > 0) takefrom++;
// if (Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]]] > 0) takefrom++;
// if (Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]] - 1] > 0) takefrom++;
// if (Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]] - 1] > 0) takefrom++;
// if (Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]] - 1] > 0) takefrom++;
// if (takefrom > 0)
// {
// if (Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]] + 1] > 0)
// {
// Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]] + 1] -= Available / takefrom;
// AboveWater[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]] + 1] = 0;
// }
// if (Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]] + 1] > 0)
// {
// Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]] + 1] -= Available / takefrom;
// AboveWater[X[ClosestBeach[j]], Y[ClosestBeach[j]] + 1] = 0;
// }
// if (Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]] + 1] > 0)
// {
// Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]] + 1] -= Available / takefrom;
// AboveWater[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]] + 1] = 0;
// }
// if (Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]]] > 0)
// {
// Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]]] -= Available / takefrom;
// AboveWater[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]]] = 0;
// }
// if (Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]]] > 0)
// {
// Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]]] -= Available / takefrom;
// AboveWater[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]]] = 0;
// }
// if (Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]] - 1] > 0)
// {
// Volume[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]] - 1] -= Available / takefrom;
// AboveWater[X[ClosestBeach[j]] - 1, Y[ClosestBeach[j]] - 1] = 0;
// }
// if (Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]] - 1] > 0)
// {
// Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]] - 1] -= Available / takefrom;
// AboveWater[X[ClosestBeach[j]], Y[ClosestBeach[j]] - 1] = 0;
// }
// if (Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]] - 1] > 0)
// {
// Volume[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]] - 1] -= Available / takefrom;
// AboveWater[X[ClosestBeach[j]] + 1, Y[ClosestBeach[j]] - 1] = 0;
// }
// }
// else // if can't find enough, just remove what's available
// {
// Volume[X[ClosestBeach[j]], Y[ClosestBeach[j]]] = 0;
// Volume[XBehind[ClosestBeach[j]], YBehind[ClosestBeach[j]]] = 0;
// AboveWater[X[ClosestBeach[j]], Y[ClosestBeach[j]]] = 0;
// AboveWater[XBehind[ClosestBeach[j]], YBehind[ClosestBeach[j]]] = 0;
// }
// }
//}
}
// Full or Empty
void OopsImFull(int x, int y)
{
//// If a cell is overfull, push beach out in new direction
//// Completely revised 5/20/02 sandrevt.c to resolve 0% full problems, etc.
//// New approach: put sand wherever 0% full in adjacent cells
//// if not 0% full, then fill all non-allbeach
//// Function adjusts primary data arrays:
//// AllBeach[][] and PercentFullSand[][]
//// LMV add rock adjustments
//int fillcells = 0;
//int fillcells2 = 0;
//if (x < pbEnd - 2)
//{
// // find out how many cells will be filled up
// if (y > 0 && (PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) == 0.0)
// {
// fillcells += 1;
// }
// if ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) == 0.0)
// {
// fillcells += 1;
// }
// if (x > 0 && (PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) == 0.0)
// {
// fillcells += 1;
// }
// if ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) == 0.0)
// {
// fillcells += 1;
// }
// if (fillcells > 0)
// {
// // Now Move Sediment
// if (y > 0 && (PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) == 0.0)
// {
// PercentFullSand[x, y - 1] += ((PercentFullSand[x, y] + PercentFullRock[x, y]) - MaxFillCell) / fillcells;
// }
// if ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) == 0.0)
// {
// PercentFullSand[x, y + 1] += ((PercentFullSand[x, y] + PercentFullRock[x, y]) - MaxFillCell) / fillcells;
// }
// if (x > 0 && (PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) == 0.0)
// {
// PercentFullSand[x - 1, y] += ((PercentFullSand[x, y] + PercentFullRock[x, y]) - MaxFillCell) / fillcells;
// }
// if ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) == 0.0)
// {
// PercentFullSand[x + 1, y] += ((PercentFullSand[x, y] + PercentFullRock[x, y]) - MaxFillCell) / fillcells;
// }
// }
// else
// {
// // No fully empty neighbors, so distribute to partially full neighbors
// if (y > 0 && (PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) < MaxFillCell)
// {
// fillcells2 += 1;
// }
// if ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) < MaxFillCell)
// {
// fillcells2 += 1;
// }
// if (x > 0 && (PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) < MaxFillCell)
// {
// fillcells2 += 1;
// }
// if ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) < MaxFillCell)
// {
// fillcells2 += 1;
// }
// if (fillcells2 > 0)
// {
// if ((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) < MaxFillCell)
// {
// PercentFullSand[x, y - 1] += ((PercentFullSand[x, y] + PercentFullRock[x, y]) - MaxFillCell) / fillcells2;
// }
// if ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) < MaxFillCell)
// {
// PercentFullSand[x, y + 1] += ((PercentFullSand[x, y] + PercentFullRock[x, y]) - MaxFillCell) / fillcells2;
// }
// if ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) < MaxFillCell)
// {
// PercentFullSand[x - 1, y] += ((PercentFullSand[x, y] + PercentFullRock[x, y]) - MaxFillCell) / fillcells2;
// }
// if ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) < MaxFillCell)
// {
// PercentFullSand[x + 1, y] += ((PercentFullSand[x, y] + PercentFullRock[x, y]) - MaxFillCell) / fillcells2;
// }
// }
// }
// if (PercentFullSand[x, y] + PercentFullRock[x, y] >= MaxFillCell)
// {
// AllBeach[x, y] = 1;
// }
// PercentFullSand[x, y] = MaxFillCell - PercentFullRock[x, y];
//}
}
void OopsImEmpty(int x, int y)
{
//// If a cell is under-full, this will find source for desparity and move brach in
//// Function completly changed 5/21/02 sandrevt.c
//// New Approach - steal from all neighboring AllBeach cells
//// Backup plan - steal from all neighboring percent full > 0
//// Function adjusts primary data arrays:
//// AllBeach[][] and PercentFullSand[][]
//// LMV Needs to be adjusted -- can't take sand from rock cells, uses AllRock[][]
//int emptycells = 0;
//int emptycells2 = 0;
////if (debug8) printf("\n OOPS I'm EMPTY! X: %d Y: %d PFS: %f PFR: %f", x, y, PercentFullSand[x][y], PercentFullRock[x][y]);
//if (x < pbEnd - 2)
//{
// if (y > 0 && (AllBeach[x, y - 1] == 1) && (PercentFullRock[x, y - 1] == 0.0))
// {
// emptycells += 1;
// }
// if ((AllBeach[x, y + 1] == 1) && (PercentFullRock[x, y + 1] == 0.0))
// {
// emptycells += 1;
// }
// if ((x > 0 && AllBeach[x - 1, y] == 1) && (PercentFullRock[x - 1, y] == 0.0))
// {
// emptycells += 1;
// }
// if ((AllBeach[x + 1, y] == 1) && (PercentFullRock[x + 1, y] == 0.0))
// {
// emptycells += 1;
// }
// if (emptycells > 0)
// {
// // Now Move Sediment
// if (y > 0 && (AllBeach[x, y - 1] == 1) && (PercentFullRock[x, y - 1] == 0.0))
// {
// PercentFullSand[x, y - 1] += PercentFullSand[x, y] / emptycells;
// AllBeach[x, y - 1] = 0;
// //if (debug8) printf(" E MOVEDBACK\n");
// //if (debug8) printf(" PFR behind: %f\n", PercentFullRock[x - 1][y]);
// //if (debug8a && PercentFullSand[x - 1][y] < 0.0)
// // printf("PFS went Negative in OopsI'mEmpty x-1: %d y:%d %f \n", x - 1, y, PercentFullSand[x - 1][y]);
// //if (debug8a && PercentFullSand[x - 1][y] > 1.0)
// // printf("PFS went >1 in OopsI'mEmpty x-1: %d y:%d %f \n", x - 1, y, PercentFullSand[x - 1][y]);
// }
// if ((AllBeach[x, y + 1] == 1) && (PercentFullRock[x, y + 1] == 0.0))
// {
// PercentFullSand[x, y + 1] += PercentFullSand[x, y] / emptycells;
// AllBeach[x, y + 1] = 0;
// //if (debug8) printf(" E MOVEDUP\n");
// //if (debug8) printf(" PFR up: %f\n", PercentFullRock[x + 1][y]);
// //if (debug8a && PercentFullSand[x + 1][y] < 0.0)
// // printf("PFS went Negative in OopsI'mEmpty x+1: %d y:%d %f \n", x + 1, y, PercentFullSand[x + 1][y]);
// //if (debug8a && PercentFullSand[x + 1][y] > 1.0)
// // printf("PFS went >1 in OopsI'mEmpty x+1: %d y:%d %f \n", x + 1, y, PercentFullSand[x + 1][y]);
// }
// if (x > 0 && (AllBeach[x - 1, y] == 1) && (PercentFullRock[x - 1, y] == 0.0))
// {
// PercentFullSand[x - 1, y] += PercentFullSand[x, y] / emptycells;
// AllBeach[x - 1, y] = 0;
// //if (debug8) printf(" E MOVEDLEFT\n");
// //if (debug8) printf(" PFR left: %f\n", PercentFullRock[x][y - 1]);
// //if (debug8a && PercentFullSand[x][y - 1] < 0.0)
// // printf("PFS went Negative in OopsI'mEmpty x: %d y-1:%d %f \n", x, y - 1, PercentFullSand[x][y - 1]);
// //if (debug8a && PercentFullSand[x][y - 1] > 1.0)
// // printf("PFS went >1 in OopsI'mEmpty x: %d y-1:%d %f \n", x, y - 1, PercentFullSand[x][y - 1]);
// }
// if ((AllBeach[x + 1, y] == 1) && (PercentFullRock[x + 1, y] == 0.0))
// {
// PercentFullSand[x + 1, y] += PercentFullSand[x, y] / emptycells;
// AllBeach[x + 1, y] = 0;
// //if (debug8) printf(" E MOVEDRIGHT\n");
// //if (debug8) printf(" PFR right: %f\n", PercentFullRock[x][y + 1]);
// //if (debug8a && PercentFullSand[x][y + 1] < 0.0)
// // printf("PFS went Negative in OopsI'mEmpty x: %d y+1:%d %f \n", x, y + 1, PercentFullSand[x][y + 1]);
// //if (debug8a && PercentFullSand[x][y - 1] > 1.0)
// // printf("PFS went >1 in OopsI'mEmpty x: %d y-1:%d %f \n", x, y - 1, PercentFullSand[x][y - 1]);
// }
// }
// else
// {
// // No full neighbors, so take away from partially full neighbors
// if (y > 0 && PercentFullSand[x, y - 1] > 0.0)
// {
// emptycells2 += 1;
// }
// if (PercentFullSand[x, y + 1] > 0.0)
// {
// emptycells2 += 1;
// }
// if (x > 0 && PercentFullSand[x - 1, y] > 0.0)
// {
// emptycells2 += 1;
// }
// if (PercentFullSand[x + 1, y] > 0.0)
// {
// emptycells2 += 1;
// }
// //if (debug8) printf("no full neighbors, counted %d partials\n", emptycells2);
// if (emptycells2 > 0)
// {
// if (y > 06 && PercentFullSand[x, y - 1] > 0.0)
// {
// PercentFullSand[x, y - 1] += PercentFullSand[x, y] / emptycells2;
// //if (debug8) printf(" E NOTFULL MOVEDBACK\n");
// //if (debug8) printf(" PFR behind: %f\n", PercentFullRock[x - 1][y]);
// //if (debug8a && PercentFullSand[x - 1][y] < 0.0)
// // printf("PFS went Negative in OopsI'mEmpty x-1: %d y:%d %f \n", x - 1, y, PercentFullSand[x - 1][y]);
// //if (debug8a && PercentFullSand[x - 1][y] > 1.0)
// // printf("PFS went >1 in OopsI'mEmpty x-1: %d y:%d %f \n", x - 1, y, PercentFullSand[x - 1][y]);
// }
// if (PercentFullSand[x, y + 1] > 0.0)
// {
// PercentFullSand[x, y + 1] += PercentFullSand[x, y] / emptycells2;
// //if (debug8) printf(" E NOTFULL MOVEDUP\n");
// //if (debug8) printf(" PFR up: %f\n", PercentFullRock[x + 1][y]);
// //if (debug8a && PercentFullSand[x + 1][y] < 0.0)
// // printf("PFS went Negative in OopsI'mEmpty x+1: %d y:%d %f \n", x + 1, y, PercentFullSand[x + 1][y]);
// //if (debug8a && PercentFullSand[x + 1][y] > 1.0)
// // printf("PFS went >1 in OopsI'mEmpty x+1: %d y:%d %f \n", x + 1, y, PercentFullSand[x + 1][y]);
// }
// if (x > 0 && PercentFullSand[x - 1, y] > 0.0)
// {
// PercentFullSand[x - 1, y] += PercentFullSand[x, y] / emptycells2;
// //if (debug8) printf(" E NOTFULL MOVEDLEFT\n");
// //if (debug8) printf(" PFR left: %f\n", PercentFullRock[x][y - 1]);
// //if (debug8a && PercentFullSand[x][y - 1] < 0.0)
// // printf("PFS went Negative in OopsI'mEmpty...Bummer x: %d y-1:%d %f \n", x, y - 1, PercentFullSand[x][y - 1]);
// //if (debug8a && PercentFullSand[x][y - 1] > 1.0)
// // printf("PFS went >1 in OopsI'mEmpty...Bummer x: %d y-1:%d %f \n", x, y - 1, PercentFullSand[x][y - 1]);
// }
// if (PercentFullSand[x + 1, y] > 0.0)
// {
// PercentFullSand[x + 1, y] += PercentFullSand[x, y] / emptycells2;
// //if (debug8) printf(" E NOTFULL MOVEDRIGHT\n");
// //if (debug8) printf(" PFR right: %f\n", PercentFullRock[x][y + 1]);
// //if (debug8a && PercentFullSand[x][y + 1] < 0.0)
// // printf("PFS went Negative in OopsI'mEmpty...Bummer x: %d y+1:%d %f \n", x, y + 1, PercentFullSand[x][y + 1]);
// //if (debug8a && PercentFullSand[x][y - 1] > 1.0)
// // printf("PFS went >1 in OopsI'mEmpty...Bummer x: %d y-1:%d %f \n", x, y - 1, PercentFullSand[x][y - 1]);
// }
// }
// //else
// //{
// // printf("@@@ Didn't find anywhere to steal sand from!! x: %d y: %d\n", x, y);
// //}
// }
// if ((PercentFullSand[x, y]) + (PercentFullRock[x, y]) < MaxFillCell)
// {
// AllBeach[x, y] = 0;
// }
// PercentFullSand[x, y] = 0.0;
// if (debug0 == 1 && PercentFullSand[58, 269] < 0.0)
// {
// StreamWriter DebugFile = new StreamWriter(DebugFilePath);
// DebugFile.Write("PercentFullSand(58,259) made underfull (" + PercentFullSand[58, 269] + ") after calling oops(" + x + ", " + y + ")\n");
// DebugFile.Close();
// //printf("^^^^^^(58,259) made underfull (%f) after calling oops(%d,%d)^^^^\n", PercentFullSand[58][269], x, y);
// }
//}
}
///Diffusion for X[i] Y[i]
void OopsImDiffusing_old()
{
int CellCount = 0;
int xHolder;
int s = 0;
//for (int k = 1; k < TotalBeachCells - 1; k++)
//{
// if (TElevationDomain[X[k], Y[k]] > (maxDomainDepth + WaterLevel + 2))
// {
// double extra = (((TElevationDomain[X[k], Y[k]] - (maxDomainDepth + WaterLevel + 0.5)) * CellWidth * CellWidth));
// Volume[X[k], Y[k]] -= extra;
// if (direction[k] == 1) // Up
// {
// extra = extra / numCells[k];
// for (int j = 0; j < numCells[k]; j++)
// {
// Volume[X[k], Y[k] + j] += extra;
// }
// }
// else if (direction[k] == 3) // Right
// {
// extra = extra / numCells[k];
// xHolder = X[k];
// for (int j = 0; j < numCells[k]; j++)
// {
// if (xHolder + s > pbEnd - 1)
// {
// xHolder = 0;
// s = 0;
// Volume[xHolder + s, Y[k]] += extra;
// s++;
// }
// else
// {
// Volume[xHolder + s, Y[k]] += extra;
// s++;
// }
// }
// }
// else if (direction[k] == 5) // Bottom
// {
// extra = extra / numCells[k];
// for (int j = 0; j < numCells[k]; j++)
// {
// Volume[X[k], Y[k] - j] += extra;
// }
// }
// else if (direction[k] == 7) // Left
// {
// extra = extra / numCells[k];
// xHolder = X[k];
// for (int j = 0; j < numCells[k]; j++)
// {
// if (xHolder - s < 0)
// {
// xHolder = pbEnd - 1;
// s = 0;
// Volume[xHolder - s, Y[k]] += extra;
// s++;
// }
// else
// {
// Volume[xHolder - s, Y[k]] += extra;
// s++;
// }
// }
// }
// }
//}
//for (int i = 1; i < TotalBeachCells - 1; i++)
//{
// int count = 0;
// double extra = 0;
// int a = 0;
// int b = 0;
// if (TElevationDomain[X[i] + a, Y[i] + b] > (maxDomainDepth + WaterLevel + 0.005))
// {
// if (AboveWater[X[i] + a, Y[i] + b + 1] == 0) // Top
// {
// count++;
// }
// //if (AboveWater[X[i] + 1, Y[i] + 1] == 0) // Top right
// //{
// // count++;
// //}
// if (AboveWater[X[i] + a + 1, Y[i] + b] == 0) // Right
// {
// count++;
// }
// //if (AboveWater[X[i] + 1, Y[i] - 1] == 0) // Bottom Right
// //{
// // count++;
// //}
// if (AboveWater[X[i] - a, Y[i] - b - 1] == 0) // Bottom
// {
// count++;
// }
// //if (AboveWater[X[i] - 1, Y[i] - 1] == 0) // Bottom Left
// //{
// // count++;
// //}
// if (AboveWater[X[i] - a - 1, Y[i] - b] == 0) // Left
// {
// count++;
// }
// //if (AboveWater[X[i] - 1, Y[i] + 1] == 0) // Top Left
// //{
// // count++;
// //}
// extra = ((TElevationDomain[X[i], Y[i]] - (maxDomainDepth + WaterLevel + 0.0025)) / count) * CellWidth * CellWidth;
// Volume[X[i], Y[i]] -= (extra * count);
// if (AboveWater[X[i] + a, Y[i] + b + 1] == 0) // Top
// {
// Volume[X[i] + a, Y[i] + b + 1] += extra;
// }
// //if (AboveWater[X[i] + 1, Y[i] + 1] == 0) // Top right
// //{
// // Volume[X[i] + 1, Y[i] + 1] += extra;
// //}
// if (AboveWater[X[i] + a + 1, Y[i] + b] == 0) // Right
// {
// Volume[X[i] + a + 1, Y[i] + b] += extra;
// }
// //if (AboveWater[X[i] + 1, Y[i] - 1] == 0) // Bottom Right
// //{
// // Volume[X[i] + 1, Y[i] - 1] += extra;
// //}
// if (AboveWater[X[i] - a, Y[i] - b - 1] == 0) // Bottom
// {
// Volume[X[i] - a, Y[i] - b - 1] += extra;
// }
// //if (AboveWater[X[i] - 1, Y[i] - 1] == 0) // Bottom Left
// //{
// // Volume[X[i] - 1, Y[i] - 1] += extra;
// //}
// if (AboveWater[X[i] - a - 1, Y[i] - b] == 0) // Left
// {
// Volume[X[i] - a - 1, Y[i] - b] += extra;
// }
// //if (AboveWater[X[i] - 1, Y[i] + 1] == 0) // Top Left
// //{
// // Volume[X[i] - 1, Y[i] + 1] += extra;
// //}
// }
//else if (TElevationDomain[X[i], Y[i]] < (maxDomainDepth + WaterLevel - 1))
//{
// if (AboveWater[X[i], Y[i] + 1] == 1) // Top
// {
// count++;
// }
// if (AboveWater[X[i] + 1, Y[i] + 1] == 1) // Top right
// {
// count++;
// }
// if (AboveWater[X[i] + 1, Y[i]] == 1) // Right
// {
// count++;
// }
// if (AboveWater[X[i] + 1, Y[i] - 1] == 1) // Bottom Right
// {
// count++;
// }
// if (AboveWater[X[i], Y[i] - 1] == 1) // Bottom
// {
// count++;
// }
// if (AboveWater[X[i] - 1, Y[i] - 1] == 1) // Bottom Left
// {
// count++;
// }
// if (AboveWater[X[i] - 1, Y[i]] == 1) // Left
// {
// count++;
// }
// if (AboveWater[X[i] - 1, Y[i] + 1] == 1) // Top Left
// {
// count++;
// }
// extra = (((maxDomainDepth + WaterLevel - 0.5) - TElevationDomain[X[i], Y[i]]) / count) * CellWidth * CellWidth;
// Volume[X[i], Y[i]] += (extra * count);
// if (AboveWater[X[i], Y[i] + 1] == 0) // Top
// {
// Volume[X[i], Y[i] + 1] -= extra;
// }
// if (AboveWater[X[i] + 1, Y[i] + 1] == 0) // Top right
// {
// Volume[X[i] + 1, Y[i] + 1] -= extra;
// }
// if (AboveWater[X[i] + 1, Y[i]] == 0) // Right
// {
// Volume[X[i] + 1, Y[i]] -= extra;
// }
// if (AboveWater[X[i] + 1, Y[i] - 1] == 0) // Bottom Right
// {
// Volume[X[i] + 1, Y[i] - 1] -= extra;
// }
// if (AboveWater[X[i], Y[i] - 1] == 0) // Bottom
// {
// Volume[X[i], Y[i] - 1] -= extra;
// }
// if (AboveWater[X[i] - 1, Y[i] - 1] == 0) // Bottom Left
// {
// Volume[X[i] - 1, Y[i] - 1] -= extra;
// }
// if (AboveWater[X[i] - 1, Y[i]] == 0) // Left
// {
// Volume[X[i] - 1, Y[i]] -= extra;
// }
// if (AboveWater[X[i] - 1, Y[i] + 1] == 0) // Top Left
// {
// Volume[X[i] - 1, Y[i] + 1] -= extra;
// }
//}
//}
// Potentially a lot of problems in here, but see how it goes!
int repeat; // want to loop through this process twice!
int x, y, n, i;
int ex, wy, en;
double[] HeightDiff = new double[4];
double[] LocalAngle = new double[4];
double[] AmountStable = new double[4];
double[] PercentAStable = new double[4];
double[] Values = new double[4];
double AStableTotal = 0;
double HeightThresholdDry = 4;
double HeightThresholdWet = 4;
double AmountAvailable;
int HighestIndex = 0;
double WetCell;
double WetCellT;
double WetCellR;
double WetCellB;
double WetCellL;
double[] Change = new double[4];
double Count;
for (repeat = 0; repeat < 2; repeat++)
{
//if (counter % 10 != 0)
//{
// //Loop through the array and apply diffusion
// for (i = 1; i < TotalBeachCells - 1; i++)
// {
// Count = 0;
// // What are the values in the cells?
// Values[0] = TElevationDomain[X[i], Y[i + 1]]; //Top
// Values[1] = TElevationDomain[X[i + 1], Y[i]]; // Right
// Values[2] = TElevationDomain[X[i], Y[i - 1]]; // Bottom
// Values[3] = TElevationDomain[X[i - 1], Y[i]]; // left
// // What is the HeightDiff between cell x and its neighbours?
// for (n = 0; n < HeightDiff.Length - 1; n++)
// {
// HeightDiff[n] = TElevationDomain[X[i], Y[i]] - Values[n];
// }
// // How much material is needed to make cells stable?
// for (n = 0; n < HeightDiff.Length - 1; n++)
// {
// // Done this so I don't get weird numbers if there is a higher neighbour.. this might cause other problems (est. too much available)
// if (HeightDiff[n] < 0)
// {
// HeightDiff[n] = 0;
// }
// AmountStable[n] = ((HeightDiff[n] - HeightThresholdDry) / 2);
// if (AmountStable[n] < 0)
// {
// AmountStable[n] = 0;
// }
// AStableTotal += AmountStable[n];
// }
// // Percentage of total material needed for each cell
// for (n = 0; n < HeightDiff.Length - 1; n++)
// {
// PercentAStable[n] = ((AmountStable[n] / AStableTotal) * 100);
// if (double.IsNaN(PercentAStable[n]) || HeightDiff[n] == 0)
// {
// PercentAStable[n] = 0;
// }
// }
// // How much material is avaialble to move?
// HighestIndex = Array.IndexOf(HeightDiff, (HeightDiff.Max())); //Using Height not values incase on is higher than x
// AmountAvailable = HeightDiff[HighestIndex] / 2;
// // Give each cell 50% of it's percentage of what's availabe - but be careful that its not more than it needs
// for (n = 0; n < HeightDiff.Length - 1; n++)
// {
// Change[n] = (((PercentAStable[n] / 100) * AmountAvailable));
// if (Change[n] > AmountStable[n])
// {
// Change[n] = AmountStable[n];
// }
// Count += Change[n];
// }
// SedimentChange[X[i], Y[i]] -= Count; // Cell x
// SedimentChange[X[i], Y[i + 1]] += (Change[0]); // Top
// SedimentChange[X[i + 1], Y[i]] += (Change[1]); // Right
// SedimentChange[X[i], Y[i - 1]] += (Change[2]); // Bottom
// SedimentChange[X[i - 1], Y[i]] += (Change[3]); // left
// AStableTotal = 0;
// }
//}
//// Whole domain - Loop through the array and apply diffusion
//else
//{
for (x = 1; x < pbEnd - 1; x++)
{
for (y = 1; y < ymax - 1; y++)
{
Count = 0;
// What are the values in the cells?
Values[0] = TElevationDomain[x, y + 1]; //Top
Values[1] = TElevationDomain[x + 1, y]; // Right
Values[2] = TElevationDomain[x, y - 1]; // Bottom
Values[3] = TElevationDomain[x - 1, y]; // left
// What is the HeightDiff between cell x and its neighbours?
for (n = 0; n < HeightDiff.Length - 1; n++)
{
HeightDiff[n] = TElevationDomain[x, y] - Values[n];
}
// How much material is needed to make cells stable?
for (n = 0; n < HeightDiff.Length - 1; n++)
{
// Done this so I don't get weird numbers if there is a higher neighbour.. this might cause other problems (est. too much available)
if (HeightDiff[n] < 0)
{
HeightDiff[n] = 0;
}
AmountStable[n] = ((HeightDiff[n] - HeightThresholdDry) / 2);
if (AmountStable[n] < 0)
{
AmountStable[n] = 0;
}
AStableTotal += AmountStable[n];
}
// Percentage of total material needed for each cell
for (n = 0; n < HeightDiff.Length - 1; n++)
{
PercentAStable[n] = ((AmountStable[n] / AStableTotal) * 100);
if (double.IsNaN(PercentAStable[n]) || HeightDiff[n] == 0)
{
PercentAStable[n] = 0;
}
}
// How much material is avaialble to move?
HighestIndex = Array.IndexOf(HeightDiff, (HeightDiff.Max())); //Using Height not values incase on is higher than x
AmountAvailable = HeightDiff[HighestIndex] / 2;
// Give each cell 50% of it's percentage of what's availabe - but be careful that its not more than it needs
for (n = 0; n < HeightDiff.Length - 1; n++)
{
Change[n] = (((PercentAStable[n] / 100) * AmountAvailable));
if (Change[n] > AmountStable[n])
{
Change[n] = AmountStable[n];
}
Count += Change[n];
}
SedimentChange[x, y] -= Count; // Cell x
SedimentChange[x, y + 1] += (Change[0]); // Top
SedimentChange[x + 1, y] += (Change[1]); // Right
SedimentChange[x, y - 1] += (Change[2]); // Bottom
SedimentChange[x - 1, y] += (Change[3]); // left
AStableTotal = 0;
}
}
}
DepthElevation();
}
void OopsImLandsliding()
{
int CellCount = 0;
int xHolder;
int s = 0;
// Potentially a lot of problems in here, but see how it goes!
int repeat; // want to loop through this process twice!
int x, y, n, i;
int ex, wy, en;
double[] HeightDiff = new double[4];
double[] LocalAngle = new double[4];
double[] AmountStable = new double[4];
double[] PercentAStable = new double[4];
double[] Values = new double[4];
double AStableTotal = 0;
double HeightThresholdDry = 1.01;
double HeightThresholdWet = 4;
double AmountAvailable;
int HighestIndex = 0;
double WetCell;
double WetCellT;
double WetCellR;
double WetCellB;
double WetCellL;
double[] Change = new double[4];
double Count;
//if (counter % 100 == 0)
//{
// for (i = 1; i < TotalBeachCells; i++)
// {
// if (TElevationDomain[X[i], Y[i]] > maxDomainDepth + WaterLevel + WDThreshold + 1)
// {
// double change_value = TElevationDomain[X[i], Y[i]] - (maxDomainDepth + WaterLevel + WDThreshold + 1);
// SedimentChange[X[i], Y[i]] -= change_value;
// if (direction[i] == 1)
// {
// SedimentChange[X[i], Y[i] + 1] += change_value;
// }
// else if (direction[i] == 3)
// {
// SedimentChange[X[i] + 1, Y[i]] += change_value;
// }
// else if (direction[i] == 5)
// {
// SedimentChange[X[i], Y[i] - 1] += change_value;
// }
// else if (direction[i] == 7)
// {
// SedimentChange[X[i] - 1, Y[i]] += change_value;
// }
// }
// }
//}
if (counter % 10 == 0 /*|| FlasgLandslide == 1*/)
{
for (repeat = 0; repeat < 2; repeat++)
{
for (x = 2; x < pbEnd - 2; x++)
{
for (y = 2; y < ymax - 2; y++)
{
//if (AboveWater[x, y] == 0 && InShadow_domain[x, y] == 1)
//{
//}
//else
//{
Count = 0;
// What are the values in the cells?
Values[0] = TElevationDomain[x, y + 1]; //Top
Values[1] = TElevationDomain[x + 1, y]; // Right
Values[2] = TElevationDomain[x, y - 1]; // Bottom
Values[3] = TElevationDomain[x - 1, y]; // left
// What is the HeightDiff between cell x and its neighbours?
for (n = 0; n < HeightDiff.Length - 1; n++)
{
HeightDiff[n] = TElevationDomain[x, y] - Values[n];
}
// How much material is needed to make cells stable?
for (n = 0; n < HeightDiff.Length - 1; n++)
{
// Done this so I don't get weird numbers if there is a higher neighbour.. this might cause other problems (est. too much available)
if (HeightDiff[n] < 0)
{
HeightDiff[n] = 0;
}
AmountStable[n] = ((HeightDiff[n] - HeightThresholdDry) / 2);
if (AmountStable[n] < 0)
{
AmountStable[n] = 0;
}
AStableTotal += AmountStable[n];
}
// Percentage of total material needed for each cell
for (n = 0; n < HeightDiff.Length - 1; n++)
{
PercentAStable[n] = ((AmountStable[n] / AStableTotal) * 100);
if (double.IsNaN(PercentAStable[n]) || HeightDiff[n] == 0)
{
PercentAStable[n] = 0;
}
}
// How much material is avaialble to move?
HighestIndex = Array.IndexOf(HeightDiff, (HeightDiff.Max())); //Using Height not values incase on is higher than x
AmountAvailable = HeightDiff[HighestIndex] / 2;
// Give each cell 50% of it's percentage of what's availabe - but be careful that its not more than it needs
for (n = 0; n < HeightDiff.Length - 1; n++)
{
Change[n] = (((PercentAStable[n] / 100) * AmountAvailable) / 2);
if (Change[n] > AmountStable[n])
{
Change[n] = AmountStable[n];
}
Count += Change[n];
}
SedimentChange[x, y] -= Count; // Cell x
SedimentChange[x, y + 1] += (Change[0]); // Top
SedimentChange[x + 1, y] += (Change[1]); // Right
SedimentChange[x, y - 1] += (Change[2]); // Bottom
SedimentChange[x - 1, y] += (Change[3]); // left
AStableTotal = 0;
//}
//}
}
DepthElevation();
}
}
//FlagLandslide = 0;
}
//if (counter % 50 == 0)
//{
// for (repeat = 0; repeat < 2; repeat++)
// {
// for (x = pbEnd - 2; x > 2; x--)
// {
// for (y = 2; y < ymax - 2; y++)
// {
// //if (AboveWater[x, y] == 0 && InShadow_domain[x, y] == 1)
// //{
// //}
// //else
// //{
// Count = 0;
// // What are the values in the cells?
// Values[0] = TElevationDomain[x, y + 1]; //Top
// Values[1] = TElevationDomain[x + 1, y]; // Right
// Values[2] = TElevationDomain[x, y - 1]; // Bottom
// Values[3] = TElevationDomain[x - 1, y]; // left
// // What is the HeightDiff between cell x and its neighbours?
// for (n = 0; n < HeightDiff.Length - 1; n++)
// {
// HeightDiff[n] = TElevationDomain[x, y] - Values[n];
// }
// // How much material is needed to make cells stable?
// for (n = 0; n < HeightDiff.Length - 1; n++)
// {
// // Done this so I don't get weird numbers if there is a higher neighbour.. this might cause other problems (est. too much available)
// if (HeightDiff[n] < 0)
// {
// HeightDiff[n] = 0;
// }
// AmountStable[n] = ((HeightDiff[n] - HeightThresholdDry) / 2);
// if (AmountStable[n] < 0)
// {
// AmountStable[n] = 0;
// }
// AStableTotal += AmountStable[n];
// }
// // Percentage of total material needed for each cell
// for (n = 0; n < HeightDiff.Length - 1; n++)
// {
// PercentAStable[n] = ((AmountStable[n] / AStableTotal) * 100);
// if (double.IsNaN(PercentAStable[n]) || HeightDiff[n] == 0)
// {
// PercentAStable[n] = 0;
// }
// }
// // How much material is avaialble to move?
// HighestIndex = Array.IndexOf(HeightDiff, (HeightDiff.Max())); //Using Height not values incase on is higher than x
// AmountAvailable = HeightDiff[HighestIndex] / 2;
// // Give each cell 50% of it's percentage of what's availabe - but be careful that its not more than it needs
// for (n = 0; n < HeightDiff.Length - 1; n++)
// {
// Change[n] = (((PercentAStable[n] / 100) * AmountAvailable) / 2);
// if (Change[n] > AmountStable[n])
// {
// Change[n] = AmountStable[n];
// }
// Count += Change[n];
// }
// SedimentChange[x, y] -= Count; // Cell x
// SedimentChange[x, y + 1] += (Change[0]); // Top
// SedimentChange[x + 1, y] += (Change[1]); // Right
// SedimentChange[x, y - 1] += (Change[2]); // Bottom
// SedimentChange[x - 1, y] += (Change[3]); // left
// AStableTotal = 0;
// //}
// //}
// }
// DepthElevation();
// }
// }
//}
//// if XY cell is too full
//if (counter % 1 == 0)
//{
// for (int j = 0; j < TotalBeachCells; j++)
// {
// if (TElevationDomain[X[j], Y[j]] > TElevationDomain[X[j], Y[j] - 1])
// {
// double difference = (TElevationDomain[X[j], Y[j]] - TElevationDomain[X[j], Y[j] - 1]);
// SedimentChange[X[j], Y[j]] -= difference;
// int count = 0;
// if (AboveWater[X[j], Y[j] + 1] == 0)
// {
// count++;
// }
// if (AboveWater[X[j] + 1, Y[j]] == 0)
// {
// count++;
// }
// if (AboveWater[X[j], Y[j] - 1] == 0)
// {
// count++;
// }
// if (AboveWater[X[j] - 1, Y[j]] == 0)
// {
// count++;
// }
// difference = difference / count;
// if (AboveWater[X[j], Y[j] + 1] == 0)
// {
// SedimentChange[X[j], Y[j] + 1] -= difference;
// }
// if (AboveWater[X[j] + 1, Y[j]] == 0)
// {
// SedimentChange[X[j] + 1, Y[j]] -= difference;
// }
// if (AboveWater[X[j], Y[j] - 1] == 0)
// {
// SedimentChange[X[j], Y[j] - 1] -= difference;
// }
// if (AboveWater[X[j] - 1, Y[j]] == 0)
// {
// SedimentChange[X[j] - 1, Y[j]] -= difference;
// }
// }
// }
// DepthElevation();
//}
//// Sweep underwater
//if (counter % 100 == 0)
//{
// for (repeat = 0; repeat < 5; repeat++)
// {
// for (x = 2; x < pbEnd - 2; x++)
// {
// for (y = 2; y < ymax - 2; y++)
// {
// if (AboveWater[x, y] == 0 || ShorelineCell[x, y] == 1)
// {
// Count = 0;
// // What are the values in the cells?
// Values[0] = TElevationDomain[x, y + 1]; //Top
// Values[1] = TElevationDomain[x + 1, y]; // Right
// Values[2] = TElevationDomain[x, y - 1]; // Bottom
// Values[3] = TElevationDomain[x - 1, y]; // left
// // What is the HeightDiff between cell x and its neighbours?
// for (n = 0; n < HeightDiff.Length - 1; n++)
// {
// HeightDiff[n] = TElevationDomain[x, y] - Values[n];
// }
// // How much material is needed to make cells stable?
// for (n = 0; n < HeightDiff.Length - 1; n++)
// {
// // Done this so I don't get weird numbers if there is a higher neighbour.. this might cause other problems (est. too much available)
// if (HeightDiff[n] < 0)
// {
// HeightDiff[n] = 0;
// }
// AmountStable[n] = ((HeightDiff[n] - HeightThresholdDry) / 2);
// if (AmountStable[n] < 0)
// {
// AmountStable[n] = 0;
// }
// AStableTotal += AmountStable[n];
// }
// // Percentage of total material needed for each cell
// for (n = 0; n < HeightDiff.Length - 1; n++)
// {
// PercentAStable[n] = ((AmountStable[n] / AStableTotal) * 100);
// if (double.IsNaN(PercentAStable[n]) || HeightDiff[n] == 0)
// {
// PercentAStable[n] = 0;
// }
// }
// // How much material is avaialble to move?
// HighestIndex = Array.IndexOf(HeightDiff, (HeightDiff.Max())); //Using Height not values incase on is higher than x
// AmountAvailable = HeightDiff[HighestIndex] / 2;
// // Give each cell 50% of it's percentage of what's availabe - but be careful that its not more than it needs
// for (n = 0; n < HeightDiff.Length - 1; n++)
// {
// Change[n] = (((PercentAStable[n] / 100) * AmountAvailable) / 2);
// if (Change[n] > AmountStable[n])
// {
// Change[n] = AmountStable[n];
// }
// Count += Change[n];
// }
// SedimentChange[x, y] -= Count; // Cell x
// SedimentChange[x, y + 1] += (Change[0]); // Top
// SedimentChange[x + 1, y] += (Change[1]); // Right
// SedimentChange[x, y - 1] += (Change[2]); // Bottom
// SedimentChange[x - 1, y] += (Change[3]); // left
// AStableTotal = 0;
// }
// }
// }
// DepthElevation();
// }
//}
//if (counter % 1 == 0)
//{
// for (x = 0; x < pbEnd - 1; x++)
// {
// for (y = 1; y < ymax - 1; y++)
// {
// if (TElevationDomain[x, y] >= TElevationDomain[x, y - 1])
// if (TElevationDomain[x, y] > TElevationDomain[x, y - 1] + 1)
// {
// SedimentChange[x, y] -= (TElevationDomain[x, y] - TElevationDomain[x, y - 1]);
// SedimentChange[x, y + 1] += (TElevationDomain[x, y] - TElevationDomain[x, y - 1]);
// }
// }
// }
// DepthElevation();
//}
//Array.Clear(Linear_Shoreline, 0, Linear_Shoreline.Length);
//for (int xx = 0; xx < pbEnd; xx++)
//{
// for (int yy = ymax - 1; yy > 0; yy--)
// {
// if (AboveWater[xx, yy] == 1)
// {
// Linear_Shoreline[xx, yy] = 1;
// break;
// }
// else
// {
// Linear_Shoreline[xx, yy] = 0;
// }
// }
//}
//if (counter % 365 == 0)
//{
// for (x = 0; x < pbEnd - 1; x++)
// {
// for (y = 1; y < ymax - 1; y++)
// {
// if (Linear_Shoreline[x, y] == 1)
// {
// //if (TElevationDomain[x, y] >= TElevationDomain[x, y - 1])
// if (TElevationDomain[x, y] > TElevationDomain[x, y - 1])
// {
// double change = (TElevationDomain[x, y] - TElevationDomain[x, y - 1]) + HeightThresholdDry;
// SedimentChange[x, y] -= change;
// SedimentChange[x, y + 1] += change;
// }
// }
// }
// }
// DepthElevation();
//}
//// If a cell is on it's own, bring it back to the coast
//if (counter % 1 == 0)
//{
// for (x = 2; x < pbEnd - 2; x++)
// {
// for (y = 2; y < ymax - 2; y++)
// {
// // if a cell is on it's own
// if (AboveWater[x, y] == 1 &&
// AboveWater[x, y + 1] == 0 &&
// AboveWater[x + 1, y] == 0 &&
// AboveWater[x, y - 1] == 0 &&
// AboveWater[x - 1, y] == 0)
// {
// double Amount = AboveWater[x, y]; // How much is in the cell
// double SurCAvg = ((TElevationDomain[x, y + 1] + TElevationDomain[x + 1, y] + TElevationDomain[x, y - 1] + TElevationDomain[x - 1, y]) / 4); // Average value of surrounding cell
// double reduce = TElevationDomain[x, y] - SurCAvg; // How much to get rid of
// if (AboveWater[x - 2, y] == 1)
// {
// SedimentChange[x - 1, y] += reduce;
// SedimentChange[x, y] -= reduce;
// }
// else if (AboveWater[x + 2, y] == 1)
// {
// SedimentChange[x + 1, y] += reduce;
// SedimentChange[x, y] -= reduce;
// }
// else
// {
// SedimentChange[x, y] -= reduce;
// SedimentChange[x, y] += reduce / 5;
// SedimentChange[x, y + 1] += reduce / 5;
// SedimentChange[x + 1, y] += reduce / 5;
// SedimentChange[x, y - 1] += reduce / 5;
// SedimentChange[x - 1, y] += reduce / 5;
// }
// }
// }
// }
// DepthElevation();
//}
}
void ShorelineLandslide()
{
int CellCount = 0;
int xHolder;
int s = 0;
// Potentially a lot of problems in here, but see how it goes!
int repeat; // want to loop through this process twice!
int x, y, n, i;
double[] HeightDiff = new double[4];
double[] LocalAngle = new double[4];
double[] AmountStable = new double[4];
double[] PercentAStable = new double[4];
double[] Values = new double[4];
double AStableTotal = 0;
double HeightThresholdDry = 1.01;
double AmountAvailable;
int HighestIndex = 0;
double[] Change = new double[4];
double Count;
for (i = 1; i < TotalBeachCells - 1; i++)
{
Count = 0;
// What are the values in the cells?
Values[0] = TElevationDomain[X[i], Y[i] + 1]; //Top
Values[1] = TElevationDomain[X[i] + 1, Y[i]]; // Right
Values[2] = TElevationDomain[X[i], Y[i] - 1]; // Bottom
Values[3] = TElevationDomain[X[i] - 1, Y[i]]; // left
// What is the HeightDiff between cell x and its neighbours?
for (n = 0; n < HeightDiff.Length - 1; n++)
{
HeightDiff[n] = TElevationDomain[X[i], Y[i]] - Values[n];
}
// How much material is needed to make cells stable?
for (n = 0; n < HeightDiff.Length - 1; n++)
{
// Done this so I don't get weird numbers if there is a higher neighbour.. this might cause other problems (est. too much available)
if (HeightDiff[n] < 0)
{
HeightDiff[n] = 0;
}
AmountStable[n] = ((HeightDiff[n] - HeightThresholdDry) / 2);
if (AmountStable[n] < 0)
{
AmountStable[n] = 0;
}
AStableTotal += AmountStable[n];
}
// Percentage of total material needed for each cell
for (n = 0; n < HeightDiff.Length - 1; n++)
{
PercentAStable[n] = ((AmountStable[n] / AStableTotal) * 100);
if (double.IsNaN(PercentAStable[n]) || HeightDiff[n] == 0)
{
PercentAStable[n] = 0;
}
}
// How much material is avaialble to move?
HighestIndex = Array.IndexOf(HeightDiff, (HeightDiff.Max())); //Using Height not values incase on is higher than x
AmountAvailable = HeightDiff[HighestIndex] / 2;
// Give each cell 50% of it's percentage of what's availabe - but be careful that its not more than it needs
for (n = 0; n < HeightDiff.Length - 1; n++)
{
Change[n] = (((PercentAStable[n] / 100) * AmountAvailable) / 2);
if (Change[n] > AmountStable[n])
{
Change[n] = AmountStable[n];
}
Count += Change[n];
}
SedimentChange[X[i], Y[i]] -= Count; // Cell x
SedimentChange[X[i], Y[i] + 1] += (Change[0]); // Top
SedimentChange[X[i] + 1, Y[i]] += (Change[1]); // Right
SedimentChange[X[i], Y[i] - 1] += (Change[2]); // Bottom
SedimentChange[X[i] - 1, Y[i]] += (Change[3]); // left
AStableTotal = 0;
}
DepthElevation();
}
void VolumeRecal()
{
// Using chnanged volume, recalculate vertical measurements
int x, y;
//StreamWriter VolChang_FILE = new StreamWriter("OUTPUT_FILES/Volchange_" + counter + ".out");
//for (y = 0; y <= ymax - 1; y++)
//{
// for (x = 0; x < pbEnd; x++)
// {
// VolChang_FILE.Write(VolumeChange[x, y] + " ");
// }
// VolChang_FILE.Write(Environment.NewLine);
//}
//VolChang_FILE.Close();
// DEBUGGING START
if (counter == 365)
{
StreamWriter DEBUG_FILE_ENDVol = File.AppendText("OUTPUT_FILES/DEBUG_FILE_ENDVol.out");
for (int s = ymax - 1; s >= 0; s--)
{
for (int r = 0; r < pbEnd; r++)
{
DEBUG_FILE_ENDVol.Write(VolumeChange[r, s] + " ");
}
DEBUG_FILE_ENDVol.Write(Environment.NewLine);
}
DEBUG_FILE_ENDVol.Close();
}
// DEBUGGING END
for (y = ymax - 1; y >= 0; y--)
{
for (x = 0; x < pbEnd; x++)
{
////if (VolumeChange[x, y] > 3)
////{
//// if (counter == 0)
//// {
//// StreamWriter VolChangeFile = new StreamWriter("OUTPUT_FILES/VolChangeExtra.out");
//// VolChangeFile.Write(x + " " + y + " " + VolumeChange[x, y] + Environment.NewLine);
//// VolChangeFile.Close();
//// }
//// else
//// {
//// StreamWriter VolChangeFile = File.AppendText("OUTPUT_FILES/VolChangeExtra.out");
//// VolChangeFile.Write(x + " " + y + " " + VolumeChange[x, y] + Environment.NewLine);
//// VolChangeFile.Close();
//// }
//// //VolumeChange[x, y] = 3;
////}
////if (VolumeChange[x, y] < -3)
////{
//// if (counter == 0)
//// {
//// StreamWriter VolChangeFile = new StreamWriter("OUTPUT_FILES/VolChangeExtra.out");
//// VolChangeFile.Write(x + " " + y + " " + VolumeChange[x, y] + Environment.NewLine);
//// VolChangeFile.Close();
//// }
//// else
//// {
//// StreamWriter VolChangeFile = File.AppendText("OUTPUT_FILES/VolChangeExtra.out");
//// VolChangeFile.Write(x + " " + y + " " + VolumeChange[x, y] + Environment.NewLine);
//// VolChangeFile.Close();
//// }
//// //VolumeChange[x, y] = -3;
////}
////else
////{
// Volume[x, y] += VolumeChange[x, y];
////}
//if (Volume[x, y] < 0)
//{
// Volume[x, y] = 0;
//}
//TElevationCS[x, y] = Volume[x, y] / (CellWidth * CellWidth);
//TElevationDomain[x, y] = TElevationCS[x, y] + DomainDepthCS[x, y];
//if (TElevationDomain[x, y] >= WaterLevel + maxDomainDepth + WDThreshold) //WetDryThreshold)
//{
// AboveWater[x, y] = 1;
//}
//else
//{
// AboveWater[x, y] = 0;
//}
//if (VolumeChange[x, y] > 3)
//{
// if (counter == 0)
// {
// StreamWriter VolChangeFile = new StreamWriter("OUTPUT_FILES/VolChangeExtra.out");
// VolChangeFile.Write(x + " " + y + " " + VolumeChange[x, y] + Environment.NewLine);
// VolChangeFile.Close();
// }
// else
// {
// StreamWriter VolChangeFile = File.AppendText("OUTPUT_FILES/VolChangeExtra.out");
// VolChangeFile.Write(x + " " + y + " " + VolumeChange[x, y] + Environment.NewLine);
// VolChangeFile.Close();
// }
///
/// Trying a new technique - 06/12/17
///
//TElevationCS[x, y] += VolumeChange[x, y];
//if (TElevationCS[x, y] < 0)
//{
// TElevationCS[x, y] = 0;
//}
//TElevationDomain[x, y] = TElevationCS[x, y] + DomainDepthCS[x, y];
//Volume[x, y] = TElevationCS[x, y] * (CellWidth * CellWidth);
//if (TElevationDomain[x, y] >= WaterLevel + maxDomainDepth + WDThreshold) //WetDryThreshold)
//{
// AboveWater[x, y] = 1;
//}
//else
//{
// AboveWater[x, y] = 0;
//}
///
/// Trying a new technique - 06/12/17
///
if(VolumeChange[x,y] < 0)
{ }
VolumeChange[x, y] = VolumeChange[x, y] *(CellWidth * CellWidth);
Volume[x, y] += VolumeChange[x, y];
TElevationCS[x, y] = Volume[x, y] / (CellWidth * CellWidth);
TElevationDomain[x, y] = TElevationCS[x, y] + DomainDepthCS[x, y];
if (TElevationDomain[x, y] >= WaterLevel + maxDomainDepth + WDThreshold) //WetDryThreshold)
{
AboveWater[x, y] = 1;
}
else
{
AboveWater[x, y] = 0;
}
}
}
Array.Clear(VolumeChange,0,VolumeChange.Length);
}
void DepthElevation()
{
// Recalculate arrays using depths and elevation etc after all material has moved during each iteration
int x, y;
//StreamWriter SedChange = new StreamWriter ("OUTPUT_FILES/sedchange.out");
for (y = ymax - 1; y >= 0; y--)
{
for (x = 0; x < pbEnd; x++)
{
TElevationCS[x, y] += SedimentChange[x, y];
// Not thinking about eroding the bed etc
if (TElevationCS[x, y] < 0)
{
TElevationCS[x, y] = 0;
}
TElevationDomain[x, y] = TElevationCS[x, y] + DomainDepthCS[x, y];
Volume[x, y] = TElevationCS[x, y] * (CellWidth * CellWidth);
if (TElevationDomain[x, y] >= WaterLevel + maxDomainDepth + WDThreshold) //WetDryThreshold)
{
AboveWater[x, y] = 1;
}
else
{
AboveWater[x, y] = 0;
}
//SedChange.Write(SedimentChange[x, y] + " ");
}
//SedChange.Write(Environment.NewLine);
}
//SedChange.Close();
Array.Clear(SedimentChange, 0, SedimentChange.Length);
}
// Calculate sediment transport
void DetermineAngles()
{
// Function to determine beach angles for all beach cells from left to right
// By convention, the ShorelineAngle will apply to current cell and right neighbor
// This function will determine global arrays: ShorelineAngle[], UpWind[], SurroundingAngle[]
// This function will use but not affect the following arrays and values: X[], Y[], PercentFull[][], AllBeach[][], WaveAngle
// ADA Revised underside, SurroundingAngle 6/03
// ADA Rerevised, 3/04
int i, j, k;
// Compute ShorelineAngle[]
// Not equal to TotalBeachCells because angle between cell and rt neighbor
for (i = 1; i < TotalBeachCells - 1; i++)
{
if (X[i] > X[i + 1])
// On bottom side of Spit (assuming we must be if going right)
{
ShorelineAngle[i] = pi - Math.Atan((Y[i + 1] - (AboveWater[X[i + 1], Y[i + 1]])) - (Y[i] - (AboveWater[X[i], Y[i]])));
if (ShorelineAngle[i] > pi)
{
ShorelineAngle[i] -= 2.0 * pi;
}
}
else if ((X[i] < X[i + 1]))
{
ShorelineAngle[i] = Math.Atan((Y[i + 1] + (AboveWater[X[i + 1], Y[i + 1]])) - (Y[i] + (AboveWater[X[i], Y[i]])));
}
else if (X[i] == X[i + 1] && Y[i] > Y[i + 1])
// Shore up and down, on right side
{
ShorelineAngle[i] = -pi / 2.0 + Math.Atan((X[i + 1] + (AboveWater[X[i + 1], Y[i + 1]])) - (X[i] + (AboveWater[X[i], Y[i]])));
}
else if (X[i] == X[i + 1] && Y[i] < Y[i + 1])
// Shore up and down, on left side
{
ShorelineAngle[i] = pi / 2.0 + Math.Atan((X[i + 1] + (AboveWater[X[i + 1], Y[i + 1]])) - (X[i] + (AboveWater[X[i], Y[i]])));
}
}
for (k = 1; k < TotalBeachCells; k++)
{
// Compute SurroundingAngle array
// Averaging doesn't work on bottom of spits
// Use trick that x is less if on bottom of spit - angles must be different signs as well
if ((X[k - 1] - X[k + 1] == 2) && (copysign(ShorelineAngle[k - 1], ShorelineAngle[k]) != ShorelineAngle[k - 1]))
{
SurroundingAngle[k] = (ShorelineAngle[k - 1] + ShorelineAngle[k]) / 2 + pi;
if (SurroundingAngle[k] > pi)
{
SurroundingAngle[k] -= 2.0 * pi;
}
}
else
{
SurroundingAngle[k] = (ShorelineAngle[k - 1] + ShorelineAngle[k]) / 2;
}
}
// Determine Upwind/downwind condition
// Note - Surrounding angle is based upon left and right cell neighbors and is centered on cell, not on right boundary
for (j = 1; j < TotalBeachCells; j++)
{
if (Math.Abs(WaveAngle - SurroundingAngle[j]) >= 42.0 / radtodeg)
{
UpWind[j] = 'u';
}
else
{
UpWind[j] = 'd';
}
}
ShorelineAngle[0] = ShorelineAngle[1];
SurroundingAngle[0] = SurroundingAngle[1];
UpWind[0] = UpWind[1];
ShorelineAngle[TotalBeachCells - 1] = ShorelineAngle[TotalBeachCells - 2];
SurroundingAngle[TotalBeachCells - 1] = SurroundingAngle[TotalBeachCells - 2];
UpWind[TotalBeachCells - 1] = UpWind[TotalBeachCells - 2];
}
void DetermineSedTransport()
{
// Loop function to determine which neigbor/situation to use for sediment transport calcs
// Once situation is determined, will use function SedTrans to determine actual transport
// This function will call ( which will determine global array: VolumeAcrossBorder[]
// This function will use but not affect the following arrays and values: X[], Y[], InShadow[], UpWind[], ShorelineAngle[], PercentFullSand[][], AllBeach[][], WaveAngle
int i;
double ShoreAngleUsed = 0;
int CalcCell;
int Next,Last;
int Correction;
char UpWindLocal;
char MaxTrans;
int DoFlux;
for (i = 1 ; i <= TotalBeachCells - 1 ; i++)
{
MaxTrans = 'n';
// Is littoral transport going left or right?
if ((WaveAngle - ShorelineAngle[i]) > 0)
{
// Transport going right, center on cell to left side of border
// Next cell in positive direction, no correction term needed
// This actually shows material moving left!!!
CalcCell = i;
Next = 1;
Last = -1;
Correction = 0;
DirectionAcrossBorder[i] = 'r';
}
else
{
// Transport going left, center on cell to right side of border
// Next cell in negative direction, correction term needed
CalcCell = i + 1;
Next = -1;
Last = 1;
Correction = -1;
DirectionAcrossBorder[i] = 'l';
}
if (InShadow[CalcCell] == 'n')
{
// Adjustment for maximum transport when passing through 45 degrees
// This adjustment is only made for moving from downwind to upwind conditions
// purposefully done before shadow adjustment, only use maxtran when transition from dw to up not because of shadow
// keeping transition from uw to dw - does not seem to be big deal
if (((UpWind[CalcCell] == 'd') && (UpWind[CalcCell+Next] == 'u') && (InShadow[CalcCell + Next] == 'n')) ||
((UpWind[CalcCell+Last] == 'u') && (UpWind[CalcCell] == 'd') && (InShadow[CalcCell+Last] == 'n')) )
{
MaxTrans = 'y';
}
// Upwind/Downwind adjustment Make sure sediment is put into shadows
// If Next cell is in shadow, use UpWind condition
DoFlux = 1;
UpWindLocal = UpWind[CalcCell];
if (InShadow[CalcCell+Next] == 'y')
{
UpWindLocal = 'u';
}
// If coming out of shadow, downwind should be used
// HOWEVER - if high angle, will result in same flux in/out problem solution - no flux for high angle waves
if ((InShadow[CalcCell+Last] == 'y') &&(UpWindLocal == 'u'))
{
DoFlux = 0;
}
// Use upwind or downwind shoreline angle for calcs
if (UpWindLocal == 'u')
{
ShoreAngleUsed = ShorelineAngle[CalcCell+Last+Correction];
}
else if (UpWindLocal == 'd')
{
ShoreAngleUsed = ShorelineAngle[CalcCell+Correction];
}
// !!! Do not do transport on underneath 'cause it gets all messed up
if ((Math.Abs(ShoreAngleUsed)) > pi/2.0)
{
DoFlux = 0;
}
// Send to SedTrans to calculate VolumeIn and VolumeOut
if (DoFlux == 1)
{
SedTrans(i, ShoreAngleUsed, MaxTrans);
}
//StreamWriter VolAc_File = File.AppendText("OUTPUT_FILES/VolAc_File.out");
//VolAc_File.Write(counter + " " + VolumeAcrossBorder[i] + Environment.NewLine);
//VolAc_File.Close();
}
}
DirectionAcrossBorder[0] = DirectionAcrossBorder[1];
DirectionAcrossBorder[TotalBeachCells - 1] = DirectionAcrossBorder[TotalBeachCells - 2];
}
void SedTrans(int i, double ShoreAngle, char MaxT)
{
// This central function will calcualte the sediment transported from the cell i-1 to the cell at i, using the input ShoreAngle LMV
// This function will caluclate and determine the global arrays: VolumeAcrossBorder[]
// This function will use the global values defining the wave field:
// WaveAngle, Period, OffShoreWvHt
// Revised 6/02 - New iterative calc for refraction and breaking, parameters revised
// Coefficients - some of these are important
double StartDepth = 3 * OffShoreWvHt; // m, depth to begin refraction calcs (needs to be beyond breakers)
double RefractStep = .2; // m, step size to iterate depth for refraction calcs
double KBreak = 0.4; // coefficient for wave breaking threshold
double rho = 1020; // kg/m3 - density of water and dissolved matter
// Variables
double AngleDeep; // rad, Angle of waves to shore at inner shelf
double Depth = StartDepth; // m, water depth for current iteration
double Angle; // rad, calculation angle
double CDeep; // m/s, phase velocity in deep water
double LDeep; // m, offhsore wavelength
double C; // m/s, current step phase velocity
double kh; // wavenumber times depth
double n;
double WaveLength; // m, current wavelength
double WvHeight; // m, current wave height
// Primary assumption is that waves refract over shore-parallel contours
// New algorithm 6/02 iteratively takes wave onshore until they break, then computes Qs
// See notes 06/05/02
AngleDeep = WaveAngle - ShoreAngle;
if (MaxT == 'y')
{
AngleDeep = pi / 4.0;
}
// Don't do calculations if over 90 degrees, should be in shadow
if (AngleDeep > 0.995 * pi / 2.0 || AngleDeep < -0.995 * pi / 2.0)
{
return;
}
else
{
// Calculate Deep Water Celerity & Length, Komar 5.11 c = gT / pi, L = CT
CDeep = g * Period / (2.0 * pi);
LDeep = CDeep * Period;
while (TRUE == 1)
{
// non-iterative eqn for L, from Fenton & McKee
WaveLength = LDeep * Raise(Math.Tanh(Raise(Raise(2.0 * pi / Period, 2) * Depth / g, .75)), 2.0 / 3.0);
C = WaveLength / Period;
// Determine n = 1/2(1+2kh/sinh(kh)) Komar 5.21
// First Calculate kh = 2 pi Depth/L from k = 2 pi/L
kh = 2 * pi * Depth / WaveLength;
n = 0.5 * (1 + 2.0 * kh / Math.Sinh(2.0 * kh));
// Calculate angle, assuming shore parallel contours and no conv/div of rays
Angle = Math.Asin(C / CDeep * Math.Sin(AngleDeep));
Angle_1[i] = Angle;
// Determine Wave height from refract calcs - Komar 5.49
WvHeight = OffShoreWvHt * Raise(CDeep * Math.Cos(AngleDeep) / (C * 2.0 * n * Math.Cos(Angle)), 0.5);
if (WvHeight > Depth * KBreak || Depth <= RefractStep)
{
break;
}
else
{
Depth -= RefractStep;
}
}
// Now Determine Transport
// eq. 9.6b (10.8) Komar, including assumption of sed density = 2650 kg/m3
// additional accuracy here will not improve an already suspect eqn for sed transport
// (especially with poorly constrained coefficients),
// so no attempt made to make this a more perfect imperfection
VolumeAcrossBorder[i] = (((Math.Abs(1.1 * rho * Raise(g, 3.0 / 2.0) * Raise(WvHeight, 2.5) * Math.Cos(Angle) * Math.Sin(Angle) * TimeStepValue)) /* (CellWidth/100)) / 2)*/));
//if (counter == 0)
//{
// StreamWriter SedTrans_FILE = File.AppendText("OUTPUT_FILES/SedTrans_FILE.out");
// SedTrans_FILE.Write(counter + " " + VolumeAcrossBorder[i] + Environment.NewLine);
// SedTrans_FILE.Close();
//}
if (i == 1)
{
VolumeAcrossBorder[0] = VolumeAcrossBorder[1];
}
/// CM bit at the end trying to check scaling! Need to check this... won't make any difference at 100m cells.
//VolumeIn/Out is now calculated in AdjustShore
//string DepthSedFile = "OUTPUT_FILES/DepthSedTrans.out";
//if (counter == 0)
//{
// StreamWriter DepthSedTrans = new StreamWriter(DepthSedFile);
// DepthSedTrans.WriteLine(counter + " " + X[i] + " " + Y[i] + VolumeAcrossBorder[i]);
// DepthSedTrans.Close();
//}
//else
//{
// StreamWriter DepthSedTrans = File.AppendText(DepthSedFile);
// DepthSedTrans.WriteLine(counter + " " + X[i] + " " + Y[i] + VolumeAcrossBorder[i]);
// DepthSedTrans.Close();
//}
//string VolAcrss_File = "OUTPUT_FILES/VolAcrss.out";
//StreamWriter VolAcross = File.AppendText(VolAcrss_File);
//VolAcross.WriteLine(counter + " " + X[i] + " " + Y[i] + " " + VolumeAcrossBorder[i]);
//VolAcross.Close();
}
}
void FlowInCell()
{
// This function will determine if sediment transport into a cell is from right, from left, converging into the cell, or diverging out */
// Purpose is to address problems with insufficent sand, fix losing sand problem
// Moves from left to right direction
// This function will affect and determine the global arrays: FlowThroughCell[]
// This function uses TotalBeachCells
// Uses but does not affect the global arrays: DirectionAcrossBorder[]
int i;
double TotalPercentInBeaches = 0;
for (i = 1; i <= TotalBeachCells; i++)
{
if ((DirectionAcrossBorder[i - 1] == 'r') && (DirectionAcrossBorder[i] == 'r'))
{
// right
FlowThroughCell[i] = 'R';
}
else if ((DirectionAcrossBorder[i - 1] == 'r') && (DirectionAcrossBorder[i] == 'l'))
{
// convergent
FlowThroughCell[i] = 'C';
}
else if ((DirectionAcrossBorder[i - 1] == 'l') && (DirectionAcrossBorder[i] == 'r'))
{
// divergent
FlowThroughCell[i] = 'D';
}
else if ((DirectionAcrossBorder[i - 1] == 'l') && (DirectionAcrossBorder[i] == 'l'))
{
// left
FlowThroughCell[i] = 'L';
}
//CM added
else
{
}
//Total Volumes in beaches!?
//TotalPercentInBeaches += (PercentFullSand[X[i], Y[i]] + PercentFullRock[X[i], Y[i]]);
TotalPercentInBeaches += TElevationCS[X[i],Y[i]];
}
if ((DirectionAcrossBorder[TotalBeachCells - 1] == 'r') && (DirectionAcrossBorder[0] == 'r'))
{
// right
FlowThroughCell[0] = 'R';
}
else if ((DirectionAcrossBorder[TotalBeachCells - 1] == 'r') && (DirectionAcrossBorder[0] == 'l'))
{
// convergent
FlowThroughCell[0] = 'C';
}
else if ((DirectionAcrossBorder[TotalBeachCells - 1] == 'l') && (DirectionAcrossBorder[0] == 'r'))
{
// divergent
FlowThroughCell[0] = 'D';
}
else if ((DirectionAcrossBorder[TotalBeachCells - 1] == 'l') && (DirectionAcrossBorder[0] == 'l'))
{
// left
FlowThroughCell[0] = 'L';
}
else
{
// right
FlowThroughCell[0] = 'R';
}
}
void FixFlow()
{
// Checks and distributes sediment in adjacent cells based on FlowThroughCell[]
// Sweeps left to right to check cells where DirectionAcrossBorder='r' (D to R, D to C, R to R, R to C)
// Sweeps right to left to check cells where DirectionAcrossBorder='l' (D to L, D to C, L to L, L to C)
// This function uses TotalBeachCells
// Uses but does not affect the global arrays: FlowThroughCell[], VolumeAcrossBorder[], PFS[][]
// reminder--VolumeAcrossBorder[] is always on right side of cell
int i;
int x, y;
double AmountSand = 0; // amount of sand availible for transport (includes amount in cell behind)
////StreamWriter DepthE = new StreamWriter("TEST_FILES/DepthE.dat");
//for (i = 0; i <= TotalBeachCells - 1; i++)
for (i = 0; i <= TotalBeachCells - 1; i++)
{
ActualVolumeAcross[i] = VolumeAcrossBorder[i];
}
// Divergent Cells - get the actual volumes across for left and right borders
for (i = 1; i <= TotalBeachCells - 1; i++)
{
// calculate effective depth
Depth = InitialDepth + ((Y[i] - InitBeach) * CellWidth * ShelfSlope);
Distance = Depth / (ShorefaceSlope - ShelfSlope * Math.Cos(ShorelineAngle[i]));
Yintercept = Y[i] + Distance * Math.Cos(ShorelineAngle[i]) / CellWidth;
DepthEffective = (InitialDepth + ((Yintercept - InitBeach) * CellWidth * ShelfSlope));
if (DepthEffective < DepthShoreface)
{
DepthEffective = DepthShoreface;
}
// set the D's first - left and right border set
if (FlowThroughCell[i] == 'D')
{
// Flow from a Divergent cell (to a Convergent cell or a Right cell)
if (AboveWater[XBehind[i], YBehind[i]] == 1)
{
//if (PercentFullRock[X[i], Y[i]] == 0.0)
//{
//AmountSand = (PercentFullSand[X[i], Y[i]] + PercentFullSand[XBehind[i], YBehind[i]]) * CellWidth * CellWidth * DepthEffective;
//AmountSand = Volume[X[i], Y[i]] + Volume[XBehind[i], YBehind[i]];
AmountSand = CellWidth * CellWidth * DepthEffective;
//}
//else
//{
// AmountSand = (PercentFullSand[X[i], Y[i]]) * CellWidth * CellWidth * DepthEffective;
// AmountSand = (Volume[X[i], Y[i]]);
//}
}
else
// I don't know how much I have, just figure it out and give me some sand
{
//AmountSand = (PercentFullSand[X[i], Y[i]]) * CellWidth * CellWidth * DepthEffective;
//AmountSand = Volume[X[i], Y[i]];
AmountSand = CellWidth * CellWidth * DepthEffective;
}
if ((VolumeAcrossBorder[i - 1] + VolumeAcrossBorder[i]) <= AmountSand)
{
ActualVolumeAcross[i] = VolumeAcrossBorder[i];
ActualVolumeAcross[i - 1] = VolumeAcrossBorder[i - 1];
}
if ((VolumeAcrossBorder[i - 1] + VolumeAcrossBorder[i]) > AmountSand)
// divide up proportionally
{
ActualVolumeAcross[i] = ((VolumeAcrossBorder[i] / (VolumeAcrossBorder[i - 1] + VolumeAcrossBorder[i])) * AmountSand);
ActualVolumeAcross[i - 1] = ((VolumeAcrossBorder[i - 1] / (VolumeAcrossBorder[i - 1] + VolumeAcrossBorder[i])) * AmountSand);
}
}
//StreamWriter D_File = File.AppendText("OUTPUT_FILES/D.dat");
//D_File.WriteLine(AmountSand);
//D_File.Close();
}
// Right Cells - get the actual volumes across right borders for R cells
for (i = 1; i <= TotalBeachCells - 1; i++)
{
// calculate effective depth
Depth = InitialDepth + ((Y[i] - InitBeach) * CellWidth * ShelfSlope);
Distance = Depth / (ShorefaceSlope - ShelfSlope * Math.Cos(ShorelineAngle[i]));
Yintercept = Y[i] + Distance * Math.Cos(ShorelineAngle[i]) / CellWidth;
DepthEffective = InitialDepth + ((Yintercept - InitBeach) * CellWidth * ShelfSlope);
if (DepthEffective < DepthShoreface)
{
DepthEffective = DepthShoreface;
}
// Flow from a Right cell (to a Right cell or a Convergent cell)
if (FlowThroughCell[i] == 'R')
{
if (AboveWater[XBehind[i], YBehind[i]] == 1)
{
//if (PercentFullRock[X[i], Y[i]] == 0.0)
//{
//AmountSand = (PercentFullSand[X[i], Y[i]] + PercentFullSand[XBehind[i], YBehind[i]]) * CellWidth * CellWidth * DepthEffective;
//AmountSand = Volume[X[i], Y[i]] + Volume[XBehind[i], YBehind[i]];
AmountSand = CellWidth * CellWidth * DepthEffective;
//}
//else
//{
// //AmountSand = (PercentFullSand[X[i], Y[i]]) * CellWidth * CellWidth * DepthEffective;
// AmountSand = (Volume[X[i], Y[i]]);
//}
}
else
// I don't know how much I have, just figure it out and give me some sand
{
//AmountSand = (PercentFullSand[X[i], Y[i]]) * CellWidth * CellWidth * DepthEffective;
//AmountSand = Volume[X[i], Y[i]];
AmountSand = CellWidth * CellWidth * DepthEffective;
}
if ((ActualVolumeAcross[i - 1] + AmountSand) >= VolumeAcrossBorder[i])
{
ActualVolumeAcross[i] = VolumeAcrossBorder[i];
}
if ((ActualVolumeAcross[i - 1] + AmountSand) < VolumeAcrossBorder[i])
{
ActualVolumeAcross[i] = ActualVolumeAcross[i - 1] + AmountSand;
}
}
//StreamWriter R_File = File.AppendText("OUTPUT_FILES/R.dat");
//R_File.WriteLine(AmountSand);
//R_File.Close();
}
// Left Cells - get the volumes across left side of cell for L cells
for (i = TotalBeachCells - 1; i >= 1; i--)
{
Depth = InitialDepth + ((Y[i] - InitBeach) * CellWidth * ShelfSlope);
Distance = Depth / (ShorefaceSlope - ShelfSlope * Math.Cos(ShorelineAngle[i]));
Yintercept = Y[i] + Distance * Math.Cos(ShorelineAngle[i]) / CellWidth;
DepthEffective = InitialDepth + ((Yintercept - InitBeach) * CellWidth * ShelfSlope);
if (DepthEffective < DepthShoreface)
{
DepthEffective = DepthShoreface;
}
// Flow from a Left cell (to a Convergent cell or a Left cell)
if (FlowThroughCell[i] == 'L')
{
if (AboveWater[XBehind[i], YBehind[i]] == 1)
{
//if (PercentFullRock[X[i], Y[i]] == 0.0)
//{
//AmountSand = (PercentFullSand[X[i], Y[i]] + PercentFullSand[XBehind[i], YBehind[i]]) * CellWidth * CellWidth * DepthEffective;
//AmountSand = Volume[X[i], Y[i]] + Volume[XBehind[i], YBehind[i]];
AmountSand = CellWidth * CellWidth * DepthEffective;
//}
//else
//{
// //AmountSand = (PercentFullSand[X[i], Y[i]]) * CellWidth * CellWidth * DepthEffective;
// AmountSand = (Volume[X[i], Y[i]]);
//}
}
else
// I don't know how much I have, just figure it out and give me some sand
{
//AmountSand = (PercentFullSand[X[i], Y[i]]) * CellWidth * CellWidth * DepthEffective;
//AmountSand = Volume[X[i], Y[i]];
AmountSand = CellWidth * CellWidth * DepthEffective;
}
if ((ActualVolumeAcross[i] + AmountSand) >= VolumeAcrossBorder[i - 1])
{
ActualVolumeAcross[i - 1] = VolumeAcrossBorder[i - 1];
}
if ((ActualVolumeAcross[i] + AmountSand) < VolumeAcrossBorder[i - 1])
{
ActualVolumeAcross[i - 1] = ActualVolumeAcross[i] + AmountSand;
}
}
//StreamWriter L_File = File.AppendText("OUTPUT_FILES/L.dat");
//L_File.WriteLine(AmountSand);
//L_File.Close();
}
ActualVolumeAcross[0] = VolumeAcrossBorder[1];
//////StreamWriter DepthE = new StreamWriter("TEST_FILES/DepthE.dat");
////for (i = 0; i <= TotalBeachCells - 1; i++)
////{
//// ActualVolumeAcross[i] = VolumeAcrossBorder[i];
////}
//// Divergent Cells - get the actual volumes across for left and right borders
//for (i = 0; i <= TotalBeachCells - 1; i++)
//{
// //// calculate effective depth
// //Depth = InitialDepth + ((Y[i] - InitBeach) * CellWidth * ShelfSlope);
// //Distance = Depth / (ShorefaceSlope - ShelfSlope * Math.Cos(ShorelineAngle[i]));
// //Yintercept = Y[i] + Distance * Math.Cos(ShorelineAngle[i]) / CellWidth;
// //DepthEffective = (InitialDepth + ((Yintercept - InitBeach) * CellWidth * ShelfSlope));
// //if (DepthEffective < DepthShoreface)
// //{
// // DepthEffective = DepthShoreface;
// //}
// // set the D's first - left and right border set
// if (FlowThroughCell[i] == 'D')
// {
// // Flow from a Divergent cell (to a Convergent cell or a Right cell)
// if (AboveWater[XBehind[i], YBehind[i]] == 1)
// {
// //if (PercentFullRock[X[i], Y[i]] == 0.0)
// //{
// //AmountSand = (PercentFullSand[X[i], Y[i]] + PercentFullSand[XBehind[i], YBehind[i]]) * CellWidth * CellWidth * DepthEffective;
// //A AmountSand = Volume[X[i], Y[i]] + Volume[XBehind[i], YBehind[i]];
// AmountSand = (((CellWidth * CellWidth) * MaxDist) + ((Elevation[X[i], Y[i]] - WaterLevel) * (CellWidth * CellWidth))) +
// (((CellWidth * CellWidth) * MaxDist) + ((Elevation[XBehind[i], YBehind[i]] - WaterLevel) * (CellWidth * CellWidth)));
// //}
// //else
// //{
// // AmountSand = (PercentFullSand[X[i], Y[i]]) * CellWidth * CellWidth * DepthEffective;
// // AmountSand = (Volume[X[i], Y[i]]);
// //}
// }
// else
// // I don't know how much I have, just figure it out and give me some sand
// {
// //AmountSand = (PercentFullSand[X[i], Y[i]]) * CellWidth * CellWidth * DepthEffective;
// //A AmountSand = Volume[X[i], Y[i]];
// AmountSand = (((CellWidth * CellWidth) * MaxDist) + ((Elevation[X[i], Y[i]] - WaterLevel) * (CellWidth * CellWidth)));
// }
// if ((VolumeAcrossBorder[i - 1] + VolumeAcrossBorder[i]) <= AmountSand)
// {
// ActualVolumeAcross[i] = VolumeAcrossBorder[i];
// ActualVolumeAcross[i - 1] = VolumeAcrossBorder[i - 1];
// }
// if ((VolumeAcrossBorder[i - 1] + VolumeAcrossBorder[i]) > AmountSand)
// // divide up proportionally
// {
// ActualVolumeAcross[i] = ((VolumeAcrossBorder[i] / (VolumeAcrossBorder[i - 1] + VolumeAcrossBorder[i])) * AmountSand);
// ActualVolumeAcross[i - 1] = ((VolumeAcrossBorder[i - 1] / (VolumeAcrossBorder[i - 1] + VolumeAcrossBorder[i])) * AmountSand);
// }
// }
// //StreamWriter SandAmountFile;
// //SandAmountFile = File.AppendText("OUTPUT_FILES/SandAmount_File.dat");
// //SandAmountFile.WriteLine(counter + " " + i + " " + FlowThroughCell[i] + " " + AmountSand);
// //SandAmountFile.Close();
// // Flow from a Right cell (to a Right cell or a Convergent cell)
// if (FlowThroughCell[i] == 'R')
// {
// if (AboveWater[XBehind[i], YBehind[i]] == 1)
// {
// //if (PercentFullRock[X[i], Y[i]] == 0.0)
// //{
// //AmountSand = (PercentFullSand[X[i], Y[i]] + PercentFullSand[XBehind[i], YBehind[i]]) * CellWidth * CellWidth * DepthEffective;
// //A AmountSand = Volume[X[i], Y[i]] + Volume[XBehind[i], YBehind[i]];
// AmountSand = (((CellWidth * CellWidth) * MaxDist) + ((Elevation[X[i], Y[i]] - WaterLevel) * (CellWidth * CellWidth))) +
// (((CellWidth * CellWidth) * MaxDist) + ((Elevation[XBehind[i], YBehind[i]] - WaterLevel) * (CellWidth * CellWidth)));
// //}
// //else
// //{
// // //AmountSand = (PercentFullSand[X[i], Y[i]]) * CellWidth * CellWidth * DepthEffective;
// // AmountSand = (Volume[X[i], Y[i]]);
// //}
// }
// else
// // I don't know how much I have, just figure it out and give me some sand
// {
// //AmountSand = (PercentFullSand[X[i], Y[i]]) * CellWidth * CellWidth * DepthEffective;
// //A AmountSand = Volume[X[i], Y[i]];
// AmountSand = (((CellWidth * CellWidth) * MaxDist) + ((Elevation[X[i], Y[i]] - WaterLevel) * (CellWidth * CellWidth)));
// }
// if ((ActualVolumeAcross[i - 1] + AmountSand) >= VolumeAcrossBorder[i])
// {
// ActualVolumeAcross[i] = VolumeAcrossBorder[i];
// }
// if ((ActualVolumeAcross[i - 1] + AmountSand) < VolumeAcrossBorder[i])
// {
// ActualVolumeAcross[i] = ActualVolumeAcross[i - 1] + AmountSand;
// }
// }
// //StreamWriter SandAmountFile;
// //SandAmountFile = File.AppendText("OUTPUT_FILES/SandAmount_File.dat");
// //SandAmountFile.WriteLine(counter + " " + i + " " + FlowThroughCell[i] + " " + AmountSand);
// //SandAmountFile.Close();
// // Flow from a Left cell (to a Convergent cell or a Left cell)
// if (FlowThroughCell[i] == 'L')
// {
// if (AboveWater[XBehind[i], YBehind[i]] == 1)
// {
// //if (PercentFullRock[X[i], Y[i]] == 0.0)
// //{
// //AmountSand = (PercentFullSand[X[i], Y[i]] + PercentFullSand[XBehind[i], YBehind[i]]) * CellWidth * CellWidth * DepthEffective;
// //A AmountSand = Volume[X[i], Y[i]] + Volume[XBehind[i], YBehind[i]];
// AmountSand = (((CellWidth * CellWidth) * MaxDist) + ((Elevation[X[i], Y[i]] - WaterLevel) * (CellWidth * CellWidth))) +
// (((CellWidth * CellWidth) * MaxDist) + ((Elevation[XBehind[i], YBehind[i]] - WaterLevel) * (CellWidth * CellWidth)));
// //}
// //else
// //{
// // //AmountSand = (PercentFullSand[X[i], Y[i]]) * CellWidth * CellWidth * DepthEffective;
// // AmountSand = (Volume[X[i], Y[i]]);
// //}
// }
// else
// // I don't know how much I have, just figure it out and give me some sand
// {
// //AmountSand = (PercentFullSand[X[i], Y[i]]) * CellWidth * CellWidth * DepthEffective;
// //A AmountSand = Volume[X[i], Y[i]];
// AmountSand = (((CellWidth * CellWidth) * MaxDist) + ((Elevation[X[i], Y[i]] - WaterLevel) * (CellWidth * CellWidth)));
// }
// if ((ActualVolumeAcross[i] + AmountSand) >= VolumeAcrossBorder[i - 1])
// {
// ActualVolumeAcross[i - 1] = VolumeAcrossBorder[i - 1];
// }
// if ((ActualVolumeAcross[i] + AmountSand) < VolumeAcrossBorder[i - 1])
// {
// ActualVolumeAcross[i - 1] = ActualVolumeAcross[i] + AmountSand;
// }
// }
// //StreamWriter AmSand = File.AppendText("OUTPUT_FILES/AmSand2.out");
// //AmSand.Write(X[i] + " " + Y[i] + " " + counter + " " + AmountSand + Environment.NewLine);
// //AmSand.Close();
//if (counter == 0 || counter % 365 == 0)
//{
// StreamWriter VolumeAcrossBorder_File = File.AppendText("OUTPUT_FILES/VolumeAcrossBorder.out");
// VolumeAcrossBorder_File.Write(Environment.NewLine);
// VolumeAcrossBorder_File.Write(counter + " " + VolumeAcrossBorder[i] + Environment.NewLine);
// VolumeAcrossBorder_File.Close();
// StreamWriter ActualVolumeAcross_File = File.AppendText("OUTPUT_FILES/ActualVolumeAcross.out");
// ActualVolumeAcross_File.Write(Environment.NewLine);
// ActualVolumeAcross_File.Write(counter + " " + ActualVolumeAcross[i] + Environment.NewLine);
// ActualVolumeAcross_File.Close();
//}
//StreamWriter AmountS_File = File.AppendText("OUTPUT_FILES/AmountS_FILE.out");
//AmountS_File.Write(AmountSand + Environment.NewLine);
//AmountS_File.Close();
//}
}
void TransportSedimentSweep()
{
// Sweep through cells to place transported sediment
// Call function AdjustShore() to move sediment.
// If cell full or overempty, call OopsImFull or OopsImEmpty()
// This function doesn't change any values, but the functions it calls do
// Uses but doesn't change: X[], Y[], PercentFullSand[]
// sweepsign added to ensure that direction of actuating changes does not
// produce unwanted artifacts (e.g. make sure symmetrical
int i,ii,sweepsign;
if (RandZeroToOne() * 2 > 1)
{
sweepsign = 1;
}
else
{
sweepsign = 0;
}
for (i = 0; i <= TotalBeachCells - 1; i++)
{
if (sweepsign == 1)
{
ii = i;
}
else
{
ii = TotalBeachCells - 1 - i;
}
AdjustShore(ii);
//VolumeRecal();
ErodeTheBeach(ii);
}
}
///
/// AdjustShore 1234 - exponentially decay amount of material in each block - problem, each block isn't the same size.
/// AdjustShore_Part2 - reduce by % at each block (try 10%, 20%)
/// AdjustShore
///
void AdjustShore_1234(int i)
{
// Complete mass balance for incoming and ougoing sediment
// This function will change the global data array PercentFullSand[][]
// Uses but does not adjust arrays: X[], Y[], ShorelineAngle[], ActualVolumeAcross LMV
// Uses global variables: ShelfSlope, CellWidth, ShorefaceSlope, InitialDepth
//FIND EFFECTIVE DEPTH, Deff, HERE
//Deff = FROM SOLUTION TO:
//A*Distance^n = D(X) - OverallSlope*cos(ShorelineAngle[X][Y])*Distance
//Where Distance is from shore, perpendicular to ShorelineAngle;
//Brad's stuff not being used right now (linear slope for now) :
//Xintercept = X + Distance*cos(ShorelineAngle), and n = 2/3.
//THEN Deff = D(Xintercept);
//FIND "A" FROM DEPTH OF 10METERS AT ABOUT 1000METERS.
//FOR NOW, USE n = 1:
double DeltaArea; // Holds change in area for cell (m^2)
if (FlowThroughCell[i] == 'L')
{
VolumeIn[i] = ActualVolumeAcross[i];
VolumeOut[i] = ActualVolumeAcross[i - 1];
}
if (FlowThroughCell[i] == 'C')
{
VolumeIn[i] = ActualVolumeAcross[i];
VolumeOut[i] = -ActualVolumeAcross[i - 1];
}
if (FlowThroughCell[i] == 'D')
{
VolumeIn[i] = -ActualVolumeAcross[i - 1];
VolumeOut[i] = ActualVolumeAcross[i];
}
if (FlowThroughCell[i] == 'R')
{
VolumeIn[i] = ActualVolumeAcross[i - 1];
VolumeOut[i] = ActualVolumeAcross[i];
}
DeltaArea = ((VolumeIn[i] - VolumeOut[i]) / 100);
//Volume[X[i], Y[i]] += DeltaArea;
//DeltaArea = (VolumeIn[i] - VolumeOut[i]);
//StreamWriter Volsout = File.AppendText("OUTPUT_FILES/Vols2.out");
//Volsout.Write(X[i] + " " + Y[i] + " " + DeltaArea + " " + counter + Environment.NewLine);
//Volsout.Close();
//DeltaArea = ((VolumeIn[i] - VolumeOut[i]) / numCells[i]) / 100;
//string DeltaAreaFile = "OUTPUT_FILES/DeltaArea.out";
//if (counter == 0)
//{
// StreamWriter DeltaAreaSW = new StreamWriter(DeltaAreaFile);
// DeltaAreaSW.WriteLine(counter + " " + X[i] + " " + Y[i] + DeltaArea);
// DeltaAreaSW.Close();
//}
//else
//{
// StreamWriter DeltaAreaSW = File.AppendText(DeltaAreaFile);
// DeltaAreaSW.WriteLine(counter + " " + X[i] + " " + Y[i] + DeltaArea);
// DeltaAreaSW.Close();
//}
//if (numCells[i] < 20)
//{
// if (DeltaArea != 0)
// {
// DeltaArea = DeltaArea/100;
// }
//}
if (DeltaArea != 0)
{
double firstDeltaArea = DeltaArea / (9000 / CellWidth); //numCells[i];
double[] block_Count = new double[200];
double blockCount = 0;
int blocks = 0;
Array.Clear(block_Count, 0, block_Count.Length);
block_Count[0] = 0;
if (double.IsInfinity(TElevationDomain[X[i], Y[i]]) || double.IsNegativeInfinity(TElevationDomain[X[i], Y[i]]))
{ }
// if numcells[i] is smaller than this number, the material will be shared between cells and block diffusion will occur
if (numCells[i] <= 20)
{
//
// Direction = 1
//
if (direction[i] == 1)
{
int a = 0;
int j = 1;
// If current cell is above the water, move to the next cell
if (AboveWater[X[i], Y[i]] == 1)
{
a = 1;
}
if (numCells[i] - a <= 0)
{
firstDeltaArea = 0;
}
else
{
firstDeltaArea /= numCells[i] - a;
}
int Count_1 = numCells[i] - a;
double leftovers = 0;
int z = a;
// Give equal amount to the row of original numcells[i]
for (int aa = a; aa < numCells[i]; aa++)
{
if (Y[i] + aa > ymax - 1 || Y[i] + aa < 0)
{
// ingnore cell
leftovers += Math.Abs(firstDeltaArea);
goto get_out_1;
}
if (X[i] < 0 || X[i] > pbEnd - 1)
{
int stop = 1;
}
if (AboveWater[X[i], Y[i] + aa] == 0)
{
Volume[X[i], Y[i] + aa] += firstDeltaArea;
}
else
{
leftovers += Math.Abs(firstDeltaArea);
}
get_out_1:
z++;
}
// how many blocks until we reach 80ish cells?
for (blocks = 0; Count_1 < 80; blocks++)
{
int xHolder = X[i] + blocks + 1;
int yHolder = Y[i] + numCells[i] - a;
int c, d, e, f, g, h;
h = 0;
// Right side - top half
for (c = 0; c <= (blocks + 1); c++)
{
if (yHolder + h > ymax - 1 || yHolder + h < 0)
{
// ingnore cell
h++;
goto y_out_1;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder + h] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_1:
blockCount++;
}
yHolder = yHolder + h - 1;
h = 1;
// Top Side
for (d = 1; d <= ((blocks + 1) * 2); d++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_2;
}
if (xHolder - h < 0 || xHolder - h > pbEnd - 1)
{
if (xHolder - h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder - h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder - h, yHolder] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_2:
blockCount++;
}
xHolder = xHolder - h + 1;
h = 1;
// Left Side
for (e = 1; e < (((blocks + 1) * 2) + numCells[i] - a); e++)
{
if (yHolder - h > ymax - 1 || yHolder - h < 0)
{
// ingnore cell
h++;
goto y_out_3;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder - h] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_3:
blockCount++;
}
yHolder = yHolder - h + 1;
h = 1;
// Bottom Side
for (f = 1; f <= (blocks + 1) * 2; f++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_4;
}
if (xHolder + h < 0 || xHolder + h > pbEnd - 1)
{
if (xHolder + h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder + h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder + h, yHolder] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_4:
blockCount++;
}
xHolder = xHolder + h - 1;
h = 1;
// Right Side - Bottom part
for (g = 1; g <= blocks + 1 + (numCells[i] - a) - 2; g++)
{
if (yHolder + h > ymax - 1 || yHolder + h < 0)
{
// ingnore cell
h++;
goto y_out_5;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder + h] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_5:
blockCount++;
}
block_Count[j] = blockCount;
blockCount++;
j++;
}
//How many blocks? How much for each block?
int posNeg;
if ((DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers) < 0)
{
posNeg = -1;
}
else
{
posNeg = 1;
}
double extraDeltaArea = Math.Abs(DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers); // How much material do we have?
double totalDeltaArea = Math.Abs(DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers); // Keep tracks of little bits that are left.
double A = Math.Abs(DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers); // End Amount
double P = 1; // Start Amount
double t = blocks; // time
//double decayRate = Math.Log(A / P) / t; // r, decay rate
double decayRate = (Math.Log(A / P)) / t;
int emptyflag = 0;
blockCount = 0;
j = 0;
// Now give those active cells some material
for (blocks = 0; (totalDeltaArea > 0) && (emptyflag == 0); blocks++)
{
int xHolder = X[i] + blocks + 1;
int yHolder = Y[i] + numCells[i] - a;
int c, d, e, f, g, h;
j++;
h = 0;
if (blocks <= t)
{
//extraDeltaArea = Math.Abs(((totalDeltaArea * decayRate) / 5) / numCells[i]);
extraDeltaArea = Math.Abs((totalDeltaArea * decayRate) / numCells[i]);
}
if (extraDeltaArea == 0)
{
extraDeltaArea = totalDeltaArea;
}
if ((double.IsInfinity(extraDeltaArea)) || (double.IsNegativeInfinity(extraDeltaArea)))
{ }
// Right side - top half
for (c = 0; c <= (blocks + 1); c++)
{
if (yHolder + h > ymax - 1 || yHolder + h < 0)
{
// ingnore cell
h++;
goto y_out_1a;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder + h] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder, yHolder + h] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder, yHolder + h] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_1a:
blockCount++;
}
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
yHolder = yHolder + h - 1;
h = 1;
// Top Side
for (d = 1; d <= ((blocks + 1) * 2); d++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_2a;
}
if (xHolder - h < 0 || xHolder - h > pbEnd - 1)
{
if (xHolder - h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder - h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder - h, yHolder] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder - h, yHolder] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder - h, yHolder] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_2a:
blockCount++;
}
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
xHolder = xHolder - h + 1;
h = 1;
// Left Side
for (e = 1; e < (((blocks + 1) * 2) + numCells[i] - a); e++)
{
if (yHolder - h > ymax - 1 || yHolder - h < 0)
{
// ingnore cell
h++;
goto y_out_3a;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder - h] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder, yHolder - h] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder, yHolder - h] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_3a:
blockCount++;
}
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
yHolder = yHolder - h + 1;
h = 1;
// Bottom Side
for (f = 1; f <= (blocks + 1) * 2; f++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_4a;
}
if (xHolder + h < 0 || xHolder + h > pbEnd - 1)
{
if (xHolder + h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder + h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder + h, yHolder] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder + h, yHolder] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder + h, yHolder] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_4a:
blockCount++;
}
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
xHolder = xHolder + h - 1;
h = 1;
// Right Side - Bottom part
for (g = 1; g <= blocks + 1 + (numCells[i] - a) - 2; g++)
{
if (yHolder + h > ymax - 1 || yHolder + h < 0)
{
// ingnore cell
h++;
goto y_out_5a;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder + h] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder, yHolder + h] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder, yHolder + h] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
y_out_5a:
blockCount++;
}
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
}
}
//
// Direction = 5
//
else if (direction[i] == 5)
{
int a = 0;
int j = 1;
// If current cell is above the water, move to the next cell
if (AboveWater[X[i], Y[i]] == 1)
{
a = 1;
}
if (numCells[i] - a <= 0)
{
firstDeltaArea = 0;
}
else
{
firstDeltaArea /= numCells[i] - a;
}
int Count_1 = numCells[i] - a;
double leftovers = 0;
int z = a;
// Give equal amount to the row of original numcells[i]
for (int aa = a; aa < numCells[i]; aa++)
{
if (Y[i] - aa > ymax - 1 || Y[i] - aa < 0)
{
// ingnore cell
leftovers += Math.Abs(firstDeltaArea);
goto get_out_2;
}
if (X[i] < 0 || X[i] > pbEnd - 1)
{
int stop = 1;
}
if (AboveWater[X[i], Y[i] - aa] == 0)
{
Volume[X[i], Y[i] - aa] += firstDeltaArea;
}
else
{
leftovers += Math.Abs(firstDeltaArea);
}
get_out_2:
z++;
}
blockCount = 0;
// how many blocks until we reach 80ish cells?
for (blocks = 0; Count_1 < 80; blocks++)
{
int xHolder = X[i] + blocks + 1;
int yHolder = Y[i] - a;
int c, d, e, f, g, h;
h = 0;
// Right side - top half
for (c = 0; c <= (blocks + 1); c++)
{
if (yHolder + h > ymax - 1 || yHolder + h < 0)
{
// ingnore cell
h++;
goto y_out_6;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder + h] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_6:
blockCount++;
}
yHolder = yHolder + h - 1;
h = 1;
// Top Side
for (d = 1; d <= ((blocks + 1) * 2); d++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_7;
}
if (xHolder - h < 0 || xHolder - h > pbEnd - 1)
{
if (xHolder - h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder - h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder - h, yHolder] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_7:
blockCount++;
}
xHolder = xHolder - h + 1;
h = 1;
// Left Side
for (e = 1; e < (((blocks + 1) * 2) + numCells[i] - a); e++)
{
if (yHolder - h > ymax - 1 || yHolder - h < 0)
{
// ingnore cell
h++;
goto y_out_8;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder - h] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_8:
blockCount++;
}
yHolder = yHolder - h + 1;
h = 1;
// Bottom Side
for (f = 1; f <= (blocks + 1) * 2; f++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_9;
}
if (xHolder + h < 0 || xHolder + h > pbEnd - 1)
{
if (xHolder + h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder + h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder + h, yHolder] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_9:
blockCount++;
}
xHolder = xHolder + h - 1;
h = 1;
// Right Side - Bottom part
for (g = 1; g <= blocks + 1 + (numCells[i] - a) - 2; g++)
{
if (yHolder + h > ymax - 1 || yHolder + h < 0)
{
// ingnore cell
h++;
goto y_out_10;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder + h] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_10:
blockCount++;
}
block_Count[j] = blockCount;
blockCount++;
j++;
}
//How many blocks? How much for each block?
int posNeg;
if ((DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers) < 0)
{
posNeg = -1;
}
else
{
posNeg = 1;
}
double extraDeltaArea = Math.Abs(DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers); // How much material do we have?
double totalDeltaArea = Math.Abs(DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers); // Keep tracks of little bits that are left.
double A = Math.Abs(DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers); // End Amount
double P = 1; // Start Amount
double t = blocks; // time
double decayRate = (Math.Log(A / P)) / t; // r, decay rate
int emptyflag = 0;
j = 0;
blockCount = 0;
// Now give those active cells some material
for (blocks = 0; (totalDeltaArea > 0) && (emptyflag == 0); blocks++)
{
int xHolder = X[i] + blocks + 1;
int yHolder = Y[i] - a;
int c, d, e, f, g, h;
h = 0;
j++;
if (blocks <= t)
{
//extraDeltaArea = Math.Abs(((totalDeltaArea * decayRate) / 5) / numCells[i]);
extraDeltaArea = Math.Abs((totalDeltaArea * decayRate) / numCells[i]);
}
if (extraDeltaArea == 0)
{
extraDeltaArea = totalDeltaArea;
}
if ((double.IsInfinity(extraDeltaArea)) || (double.IsNegativeInfinity(extraDeltaArea)))
{ }
// Right side - top half
for (c = 0; c <= (blocks + 1); c++)
{
if (yHolder + h > ymax - 1 || yHolder + h < 0)
{
// ingnore cell
h++;
goto y_out_6a;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder + h] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder, yHolder + h] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder, yHolder + h] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_6a:
blockCount++;
}
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
yHolder = yHolder + h - 1;
h = 1;
// Top Side
for (d = 1; d <= ((blocks + 1) * 2); d++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_7a;
}
if (xHolder - h < 0 || xHolder - h > pbEnd - 1)
{
if (xHolder - h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder - h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder - h, yHolder] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder - h, yHolder] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder - h, yHolder] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_7a:
blockCount++;
}
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
xHolder = xHolder - h + 1;
h = 1;
// Left Side
for (e = 1; e < (((blocks + 1) * 2) + numCells[i] - a); e++)
{
if (yHolder - h > ymax - 1 || yHolder - h < 0)
{
// ingnore cell
h++;
goto y_out_8a;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder - h] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder, yHolder - h] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder, yHolder - e] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_8a:
blockCount++;
}
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
yHolder = yHolder - h + 1;
h = 1;
// Bottom Side
for (f = 1; f <= (blocks + 1) * 2; f++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_9a;
}
if (xHolder + h < 0 || xHolder + h > pbEnd - 1)
{
if (xHolder + h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder + h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder + h, yHolder] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder + h, yHolder] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder + h, yHolder] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_9a:
blockCount++;
}
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
xHolder = xHolder + h - 1;
h = 1;
// Right Side - Bottom part
for (g = 1; g <= blocks + 1 + (numCells[i] - a) - 2; g++)
{
if (yHolder + h > ymax - 1 || yHolder + h < 0)
{
// ingnore cell
h++;
goto y_out_10a;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder + h] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder, yHolder + h] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder, yHolder + h] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_10a:
blockCount++;
}
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
}
}
//
// Direction = 3
//
else if (direction[i] == 3)
{
int a = 0;
int j = 1;
double leftovers = 0;
// If current cell is above the water, move to the next cell
if (AboveWater[X[i], Y[i]] == 1)
{
a = 1;
}
if (numCells[i] - a <= 0)
{
firstDeltaArea = 0;
}
else
{
firstDeltaArea /= numCells[i] - a;
}
int Count_1 = numCells[i] - a;
int z = a;
// Give equal amount to the row of original numcells[i]
for (int aa = a; aa < numCells[i]; aa++)
{
if (Y[i] > ymax - 1 || Y[i] < 0)
{
// ingnore cell
leftovers += Math.Abs(firstDeltaArea);
goto get_out_3;
}
if (X[i] + z < 0 || X[i] + z > pbEnd - 1)
{
if (X[i] + z < 0)
{
z = pbEnd - 1;
}
else if (X[i] + z > pbEnd - 1)
{
z = 0;
}
}
if (AboveWater[X[i] + z, Y[i]] == 0)
{
Volume[X[i] + z, Y[i]] += firstDeltaArea;
}
else
{
leftovers += Math.Abs(firstDeltaArea);
}
get_out_3:
z++;
}
// how many blocks until we reach 80ish cells?
for (blocks = 0; Count_1 < 80; blocks++)
{
int xHolder = X[i] + numCells[i] - a;
int yHolder = Y[i] + blocks + 1;
int c, d, e, f, g, h;
h = 1;
// Top side - Left half
for (c = 0; c < ((blocks + 1) + numCells[i] - a - 1); c++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_11;
}
if (xHolder - h < 0 || xHolder - h > pbEnd - 1)
{
if (xHolder - h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder - h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder - h, yHolder] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_11:
blockCount++;
}
xHolder = xHolder - h + 1;
h = 1;
// Left Side
for (d = 1; d <= (blocks + 1) * 2; d++)
{
if (yHolder - h > ymax - 1 || yHolder - h < 0)
{
// ingnore cell
h++;
goto y_out_12;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder - h] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_12:
blockCount++;
}
yHolder = yHolder - h + 1;
h = 1;
// Bottom Side
for (e = 1; e < (((blocks + 1) * 2) + numCells[i] - a); e++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_13;
}
if (xHolder + h < 0 || xHolder + h > pbEnd - 1)
{
if (xHolder + h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder + h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder + h, yHolder] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_13:
blockCount++;
}
xHolder = xHolder + h - 1;
h = 1;
// Right Side
for (f = 1; f <= (blocks + 1) * 2; f++)
{
if (yHolder + h > ymax - 1 || yHolder + h < 0)
{
// ingnore cell
h++;
goto y_out_14;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder + h] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_14:
blockCount++;
}
yHolder = yHolder + h - 1;
h = 1;
// Top Side - Right part
for (g = 1; g <= blocks + 1; g++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_15;
}
if (xHolder - h < 0 || xHolder - h > pbEnd - 1)
{
if (xHolder - h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder - h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder - h, yHolder] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_15:
blockCount++;
}
block_Count[j] = blockCount;
blockCount++;
j++;
}
//How many blocks? How much for each block?
int posNeg;
if ((DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers) < 0)
{
posNeg = -1;
}
else
{
posNeg = 1;
}
double extraDeltaArea = Math.Abs(DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers); // How much material do we have?
double totalDeltaArea = Math.Abs(DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers); // Keep tracks of little bits that are left.
double A = Math.Abs(DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers); // End Amount
double P = 1; // Start Amount
double t = blocks; // time
double decayRate = (Math.Log(A / P)) / t; // r, decay rate
int emptyflag = 0;
j = 0;
// Now give those active cells some material
for (blocks = 0; (totalDeltaArea > 0) && (emptyflag == 0); blocks++)
{
int xHolder = X[i] + numCells[i] - a;
int yHolder = Y[i] + blocks + 1;
int c, d, e, f, g, h;
j++;
if (blocks <= t)
{
//extraDeltaArea = Math.Abs(((totalDeltaArea * decayRate) / 5) / numCells[i]);
extraDeltaArea = Math.Abs((totalDeltaArea * decayRate) / numCells[i]);
}
if (extraDeltaArea == 0)
{
extraDeltaArea = totalDeltaArea;
}
if ((double.IsInfinity(extraDeltaArea)) || (double.IsNegativeInfinity(extraDeltaArea)))
{ }
h = 1;
// Top side - Left half
for (c = 0; c < ((blocks + 1) + numCells[i] - a - 1); c++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_11a;
}
if (xHolder - h < 0 || xHolder - h > pbEnd - 1)
{
if (xHolder - h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder - h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder - h, yHolder] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder - h, yHolder] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder - h, yHolder] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_11a:
blockCount++;
}
xHolder = xHolder - h + 1;
h = 1;
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
// Left Side
for (d = 1; d <= (blocks + 1) * 2; d++)
{
if (yHolder - h > ymax - 1 || yHolder - h < 0)
{
// ingnore cell
h++;
goto y_out_12a;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder - h] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder, yHolder - h] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder, yHolder - h] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_12a:
blockCount++;
}
yHolder = yHolder - h + 1;
h = 1;
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
// Bottom Side
for (e = 1; e < (((blocks + 1) * 2) + numCells[i] - a); e++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_13a;
}
if (xHolder + h < 0 || xHolder + h > pbEnd - 1)
{
if (xHolder + h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder + h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder + h, yHolder] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder + h, yHolder] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder + h, yHolder] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_13a:
blockCount++;
}
xHolder = xHolder + h - 1;
h = 1;
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
// Right Side
for (f = 1; f <= (blocks + 1) * 2; f++)
{
if (counter == 6)
{
int stop = 1;
}
if (yHolder + h > ymax - 1 || yHolder + h < 0)
{
// ingnore cell
h++;
goto y_out_14a;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder + h] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder, yHolder + h] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder, yHolder + h] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_14a:
blockCount++;
}
yHolder = yHolder + h - 1;
h = 1;
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
// Top Side - Right part
for (g = 1; g <= blocks + 1; g++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_15a;
}
if (xHolder - h < 0 || xHolder - h > pbEnd - 1)
{
if (xHolder - h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder - h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder - h, yHolder] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder - h, yHolder] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder - h, yHolder] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_15a:
blockCount++;
}
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
}
}
//
// Direction = 7
//
else if (direction[i] == 7)
{
int a = 0;
int j = 1;
double leftovers = 0;
// If current cell is above the water, move to the next cell
if (AboveWater[X[i], Y[i]] == 1)
{
a = 1;
}
if (numCells[i] - a <= 0)
{
firstDeltaArea = 0;
}
else
{
firstDeltaArea /= numCells[i] - a;
}
int Count_1 = numCells[i] - a;
int z = a;
// Give equal amount to the row of original numcells[i]
for (int aa = a; aa < numCells[i]; aa++)
{
if (Y[i] > ymax - 1 || Y[i] < 0)
{
// ingnore cell
leftovers += Math.Abs(firstDeltaArea);
goto get_out_4;
}
if (X[i] - z < 0 || X[i] - z > pbEnd - 1)
{
if (X[i] - z < 0)
{
z = pbEnd - 1;
}
else if (X[i] - z > pbEnd - 1)
{
z = 0;
}
}
if (AboveWater[X[i] - z, Y[i]] == 0)
{
Volume[X[i] - z, Y[i]] += firstDeltaArea;
}
else
{
leftovers += Math.Abs(firstDeltaArea);
}
get_out_4:
z++;
}
// how many blocks until we reach 80ish cells?
for (blocks = 0; Count_1 < 80; blocks++)
{
int xHolder = X[i] - a;
int yHolder = Y[i] + blocks + 1;
int c, d, e, f, g, h;
h = 0;
// Top side - Left half
for (c = 0; c < ((blocks + 1) + numCells[i] - a - 1); c++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_11;
}
if (xHolder - h < 0 || xHolder - h > pbEnd - 1)
{
if (xHolder - h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder - h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder - h, yHolder] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_11:
blockCount++;
}
xHolder = xHolder - h + 1;
h = 1;
// Left Side
for (d = 1; d <= (blocks + 1) * 2; d++)
{
if (yHolder - h > ymax - 1 || yHolder - h < 0)
{
// ingnore cell
h++;
goto y_out_12;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder - h] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_12:
blockCount++;
}
yHolder = yHolder - h + 1;
h = 1;
// Bottom Side
for (e = 1; e < (((blocks + 1) * 2) + numCells[i] - a); e++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_13;
}
if (xHolder + h < 0 || xHolder + h > pbEnd - 1)
{
if (xHolder + h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder + h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder + h, yHolder] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_13:
blockCount++;
}
xHolder = xHolder + h - 1;
h = 1;
// Right Side
for (f = 1; f <= (blocks + 1) * 2; f++)
{
if (yHolder + h > ymax - 1 || yHolder + h < 0)
{
// ingnore cell
h++;
goto y_out_14;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder + h] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_14:
blockCount++;
}
yHolder = yHolder + h - 1;
h = 1;
// Top Side - Right part
for (g = 1; g <= blocks + 1; g++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_15;
}
if (xHolder - h < 0 || xHolder - h > pbEnd - 1)
{
if (xHolder - h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder - h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder - h, yHolder] == 0)
{
Count_1++;
h++;
}
else
{
h++;
}
y_out_15:
blockCount++;
}
block_Count[j] = blockCount;
blockCount++;
j++;
}
//How many blocks? How much for each block?
int posNeg;
if ((DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers) < 0)
{
posNeg = -1;
}
else
{
posNeg = 1;
}
double extraDeltaArea = Math.Abs(DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers); // How much material do we have?
double totalDeltaArea = Math.Abs(DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers); // Keep tracks of little bits that are left.
double A = Math.Abs(DeltaArea - (firstDeltaArea * numCells[i] - a) + leftovers); // End Amount
double P = 1; // Start Amount
double t = blocks; // time
double decayRate = (Math.Log(A / P)) / t; // r, decay rate
if (counter == 555 && i == 119)
{ }
int emptyflag = 0;
j = 0;
// Now give those active cells some material
for (blocks = 0; (totalDeltaArea > 0) && (emptyflag == 0); blocks++)
{
int xHolder = X[i] - a;
int yHolder = Y[i] + blocks + 1;
int c, d, e, f, g, h;
j++;
if (blocks <= t)
{
//extraDeltaArea = Math.Abs(((totalDeltaArea * decayRate) / 5) / numCells[i]);
extraDeltaArea = Math.Abs((totalDeltaArea * decayRate) / numCells[i]);
}
if (extraDeltaArea == 0)
{
extraDeltaArea = totalDeltaArea;
}
if ((double.IsInfinity(extraDeltaArea)) || (double.IsNegativeInfinity(extraDeltaArea)))
{ }
h = 0;
// Top side - Left half
for (c = 0; c < ((blocks + 1) + numCells[i] - a - 1); c++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_11a;
}
if (xHolder - h < 0 || xHolder - h > pbEnd - 1)
{
if (xHolder - h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder - h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder - h, yHolder] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder - h, yHolder] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder - h, yHolder] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_11a:
blockCount++;
}
xHolder = xHolder - h + 1;
h = 1;
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
// Left Side
for (d = 1; d <= (blocks + 1) * 2; d++)
{
if (yHolder - h > ymax - 1 || yHolder - h < 0)
{
// ingnore cell
h++;
goto y_out_12a;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder - h] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder, yHolder - h] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder, yHolder - h] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_12a:
blockCount++;
}
yHolder = yHolder - h + 1;
h = 1;
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
// Bottom Side
for (e = 1; e < (((blocks + 1) * 2) + numCells[i] - a); e++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_13a;
}
if (xHolder + h < 0 || xHolder + h > pbEnd - 1)
{
if (xHolder + h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder + h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder + h, yHolder] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder + h, yHolder] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder + h, yHolder] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_13a:
blockCount++;
}
xHolder = xHolder + h - 1;
h = 1;
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
// Right Side
for (f = 1; f <= (blocks + 1) * 2; f++)
{
if (yHolder + h > ymax - 1 || yHolder + h < 0)
{
// ingnore cell
h++;
goto y_out_14a;
}
if (xHolder < 0 || xHolder > pbEnd - 1)
{
if (xHolder < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder > pbEnd - 1)
{
xHolder = 0;
}
}
if (AboveWater[xHolder, yHolder + h] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder, yHolder + h] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder, yHolder + h] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_14a:
blockCount++;
}
yHolder = yHolder + h - 1;
h = 1;
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
// Top Side - Right part
for (g = 1; g <= blocks + 1; g++)
{
if (yHolder > ymax - 1 || yHolder < 0)
{
// ingnore cell
h++;
goto y_out_15a;
}
if (xHolder - h < 0 || xHolder - h > pbEnd - 1)
{
if (xHolder - h < 0)
{
xHolder = pbEnd - 1;
}
else if (xHolder - h > pbEnd - 1)
{
xHolder = 0;
}
h = 0;
}
if (AboveWater[xHolder - h, yHolder] == 0)
{
if (totalDeltaArea <= extraDeltaArea)
{
Volume[xHolder - h, yHolder] += totalDeltaArea * posNeg;
totalDeltaArea = 0;
emptyflag = 1;
h++;
break;
}
else
{
Volume[xHolder - h, yHolder] += extraDeltaArea * posNeg;
totalDeltaArea -= extraDeltaArea;
h++;
}
}
else
{
h++;
}
y_out_15a:
blockCount++;
}
if (totalDeltaArea <= 0)
{
emptyflag = 1;
break;
}
}
}
}
else if (DeltaArea > 0 && numCells[i] > 20)
{
if (AboveWater[X[i], Y[i]] == 1)
{
if (direction[i] == 1)
{
Volume[X[i], Y[i] + 1] += firstDeltaArea;
//Y[i] = Y[i] + 1;
}
else if (direction[i] == 2)
{
Volume[X[i] + 1, Y[i] + 1] += firstDeltaArea;
//X[i] = X[i] + 1;
}
else if (direction[i] == 3)
{
Volume[X[i] + 1, Y[i]] += firstDeltaArea;
//X[i] = X[i] + 1;
}
else if (direction[i] == 4)
{
Volume[X[i] + 1, Y[i] - 1] += firstDeltaArea;
//X[i] = X[i] + 1;
//Y[i] = Y[i] - 1;
}
else if (direction[i] == 5)
{
Volume[X[i], Y[i] - 1] += firstDeltaArea;
//Y[i] = Y[i] - 1;
}
else if (direction[i] == 6)
{
Volume[X[i] - 1, Y[i] - 1] += firstDeltaArea;
//X[i] = X[i] - 1;
//Y[i] = Y[i] - 1;
}
else if (direction[i] == 7)
{
Volume[X[i] - 1, Y[i]] += firstDeltaArea;
//X[i] = X[i] - 1;
}
else if (direction[i] == 8)
{
Volume[X[i] - 1, Y[i] + 1] += firstDeltaArea;
//Y[i] = Y[i] + 1;
//X[i] = X[i] - 1;
}
//Volume[X[i], Y[i]] += 0;
numCells[i]--;
}
else
{
Volume[X[i], Y[i]] += firstDeltaArea;
numCells[i]--;
}
int xHolder;
int s = 0;
double extraDeltaArea = DeltaArea - firstDeltaArea; // How much material do we have?
double totalDeltaArea = DeltaArea - firstDeltaArea; // Keep tracks of little bits that are left.
double A = DeltaArea - firstDeltaArea; // End Amount
double P = 1; // Start Amount
double t = numCells[i]; // time
if (numCells[i] <= 0)
{
numCells[i] = 1;
t = 1;
}
double decayRate = Math.Log(A / P) / t; // r, decay rate
if (direction[i] == 1) // Up
{
for (int j = 0; j < numCells[i]; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
if (j == numCells[i] - 1)
{
Volume[X[i], Y[i] + j] += totalDeltaArea;
}
else
{
Volume[X[i], Y[i] + j] += extraDeltaArea;
}
totalDeltaArea -= extraDeltaArea;
}
}
else if (direction[i] == 3) // Right
{
xHolder = X[i];
for (int j = 0; j < numCells[i]; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
if (xHolder + s > pbEnd - 1)
{
xHolder = 0;
s = 0;
}
if (j == numCells[i] - 1)
{
Volume[xHolder + s, Y[i]] += totalDeltaArea;
s++;
}
else
{
Volume[xHolder + s, Y[i]] += extraDeltaArea;
s++;
}
totalDeltaArea -= extraDeltaArea;
}
}
else if (direction[i] == 5) // Bottom
{
for (int j = 0; j < numCells[i]; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
if (j == numCells[i] - 1)
{
Volume[X[i], Y[i] - j] += totalDeltaArea;
}
else
{
Volume[X[i], Y[i] - j] += extraDeltaArea;
}
totalDeltaArea -= extraDeltaArea;
}
}
else if (direction[i] == 7) // Left
{
xHolder = X[i];
for (int j = 0; j < numCells[i]; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
if (xHolder - s < 0)
{
xHolder = pbEnd - 1;
s = 0;
}
if (j == numCells[i] - 1)
{
Volume[xHolder - s, Y[i]] += totalDeltaArea;
}
else
{
Volume[xHolder - s, Y[i]] += extraDeltaArea;
s++;
}
totalDeltaArea -= extraDeltaArea;
}
}
// int CellCount = 0;
// int xHolder;
// int s = 0;
// // How many cells out does the slope extend (only to a dip in the coastline)
// if (direction[i] == 1) // Top
// {
// for (CellCount = 0; CellCount < numCells[i]; CellCount++)
// {
// Volume[X[i], Y[i] + s] += DeltaArea;
// s++;
// }
// }
// else if (direction[i] == 2) // Top Right
// {
// for (CellCount = 0; CellCount < numCells[i]; CellCount++)
// {
// Volume[X[i] + s, Y[i] + s] += DeltaArea;
// s++;
// }
// }
// else if (direction[i] == 3) // Right
// {
// xHolder = X[i];
// //if (AboveWater[xHolder + 1, Y[i]] == 1)
// //{
// // Y[i] = Y[i] + 1;
// //}
// for (CellCount = 0; CellCount < numCells[i]; CellCount++)
// {
// if (xHolder + s > pbEnd - 1)
// {
// xHolder = 0;
// s = 0;
// Volume[xHolder + s, Y[i]] += DeltaArea;
// s++;
// }
// else
// {
// Volume[xHolder + s, Y[i]] += DeltaArea;
// s++;
// }
// }
// }
// else if (direction[i] == 4) // Bottom Right
// {
// for (CellCount = 0; CellCount < numCells[i]; CellCount++)
// {
// Volume[X[i] + s, Y[i] - s] += DeltaArea;
// s++;
// }
// }
// else if (direction[i] == 5) // Bottom
// {
// for (CellCount = 0; CellCount < numCells[i]; CellCount++)
// {
// Volume[X[i], Y[i] - s] += DeltaArea;
// s++;
// }
// }
// else if (direction[i] == 6) // Bottom Left
// {
// for (CellCount = 0; CellCount < numCells[i]; CellCount++)
// {
// Volume[X[i] - s, Y[i] - s] += DeltaArea;
// s++;
// }
// }
// else if (direction[i] == 7) // Left
// {
// xHolder = X[i];
// //if (AboveWater[xHolder - 1, Y[i]] == 1)
// //{
// // Y[i] = Y[i] + 1;
// //}
// for (CellCount = 0; CellCount < numCells[i]; CellCount++)
// {
// if (xHolder - s < 0)
// {
// xHolder = pbEnd - 1;
// s = 0;
// Volume[xHolder - s, Y[i]] += DeltaArea;
// s++;
// }
// else
// {
// Volume[xHolder - s, Y[i]] += DeltaArea;
// s++;
// }
// }
// }
// else if (direction[i] == 8) // Top Left
// {
// for (CellCount = 0; CellCount < numCells[i]; CellCount++)
// {
// Volume[X[i] - s, Y[i] + s] += DeltaArea;
// s++;
// }
// }
}
else if (DeltaArea < 0 && numCells[i] > 20)
{
Volume[X[i], Y[i]] += firstDeltaArea;
numCells[i]--;
int xHolder;
int s = 0;
double extraDeltaArea = Math.Abs(DeltaArea - firstDeltaArea); // How much material do we have?
double totalDeltaArea = Math.Abs(DeltaArea - firstDeltaArea); // Keep tracks of little bits that are left.
double A = Math.Abs(DeltaArea - firstDeltaArea); // End Amount
double P = 1; // Start Amount
double t = numCells[i]; // time
if (numCells[i] <= 0)
{
numCells[i] = 1;
t = 1;
}
double decayRate = Math.Log(A / P) / t; // r, decay rate
if (direction[i] == 1) // Up
{
for (int j = 0; j < numCells[i]; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
if (j == numCells[i] - 1)
{
Volume[X[i], Y[i] + j] -= extraDeltaArea;
}
else
{
Volume[X[i], Y[i] + j] -= extraDeltaArea;
}
totalDeltaArea -= extraDeltaArea;
}
}
else if (direction[i] == 3) // Right
{
xHolder = X[i];
for (int j = 0; j < numCells[i]; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
if (xHolder + s > pbEnd - 1)
{
xHolder = 0;
s = 0;
}
if (j == numCells[i] - 1)
{
Volume[xHolder + s, Y[i]] -= totalDeltaArea;
s++;
}
else
{
Volume[xHolder + s, Y[i]] -= extraDeltaArea;
s++;
}
totalDeltaArea -= extraDeltaArea;
}
}
else if (direction[i] == 5) // Bottom
{
for (int j = 0; j < numCells[i]; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
if (j == numCells[i] - 1)
{
Volume[X[i], Y[i] - j] -= totalDeltaArea;
}
else
{
Volume[X[i], Y[i] - j] -= extraDeltaArea;
}
totalDeltaArea -= extraDeltaArea;
}
}
else if (direction[i] == 7) // Left
{
xHolder = X[i];
for (int j = 0; j < numCells[i]; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
if (xHolder - s < 0)
{
xHolder = pbEnd - 1;
s = 0;
}
if (j == numCells[i] - 1)
{
Volume[xHolder - s, Y[i]] -= totalDeltaArea;
}
else
{
Volume[xHolder - s, Y[i]] -= extraDeltaArea;
s++;
}
totalDeltaArea -= extraDeltaArea;
}
}
}
if (double.IsInfinity(TElevationDomain[X[i], Y[i]]) || double.IsNegativeInfinity(TElevationDomain[X[i], Y[i]]))
{ }
}
if (double.IsInfinity(TElevationDomain[X[i], Y[i]]) || double.IsNegativeInfinity(TElevationDomain[X[i], Y[i]]))
{ }
}
void AdjustShore_Part2(int i)
{
// Complete mass balance for incoming and ougoing sediment
// This function will change the global data array PercentFullSand[][]
// Uses but does not adjust arrays: X[], Y[], ShorelineAngle[], ActualVolumeAcross LMV
// Uses global variables: ShelfSlope, CellWidth, ShorefaceSlope, InitialDepth
//FIND EFFECTIVE DEPTH, Deff, HERE
//Deff = FROM SOLUTION TO:
//A*Distance^n = D(X) - OverallSlope*cos(ShorelineAngle[X][Y])*Distance
//Where Distance is from shore, perpendicular to ShorelineAngle;
//Brad's stuff not being used right now (linear slope for now) :
//Xintercept = X + Distance*cos(ShorelineAngle), and n = 2/3.
//THEN Deff = D(Xintercept);
//FIND "A" FROM DEPTH OF 10METERS AT ABOUT 1000METERS.
//FOR NOW, USE n = 1:
double DeltaArea; // Holds change in area for cell (m^2)
if (FlowThroughCell[i] == 'L')
{
VolumeIn[i] = ActualVolumeAcross[i];
VolumeOut[i] = ActualVolumeAcross[i - 1];
}
if (FlowThroughCell[i] == 'C')
{
VolumeIn[i] = ActualVolumeAcross[i];
VolumeOut[i] = -ActualVolumeAcross[i - 1];
}
if (FlowThroughCell[i] == 'D')
{
VolumeIn[i] = -ActualVolumeAcross[i - 1];
VolumeOut[i] = ActualVolumeAcross[i];
}
if (FlowThroughCell[i] == 'R')
{
VolumeIn[i] = ActualVolumeAcross[i - 1];
VolumeOut[i] = ActualVolumeAcross[i];
}
//if (X[i] == xDisplayStart)
//{
//}
//if (X[i] == pbEnd / 2)
//{
// StreamWriter SandOut_File_m = File.AppendText("OUTPUT_FILES/SandOut_middle.out");
// SandOut_File_m.Write(counter + " " + X[i] + " " + Y[i] + " " + ((VolumeOut[i] / CellWidth) / 2) + Environment.NewLine);
// SandOut_File_m.Close();
//}
//if (X[i] == xDisplayEnd)
//{
// StreamWriter SandOut_File_e = File.AppendText("OUTPUT_FILES/SandOut_end.out");
// SandOut_File_e.Write(counter + " " + X[i] + " " + Y[i] + " " + ((VolumeOut[i] / CellWidth) / 2) + Environment.NewLine);
// SandOut_File_e.Close();
//}
//DeltaArea = ((((VolumeIn[i] - VolumeOut[i]) / 100) / 2));
DeltaArea = (VolumeIn[i] - VolumeOut[i]) / (CellWidth * CellWidth);
//if (X[i] == 1000 && Y[i] > 250 && hit == 0)
//{
// StreamWriter SandOut_File_s = File.AppendText("OUTPUT_FILES/SandOut_start.out");
// //StreamWriter Delta_File = File.AppendText("OUTPUT_FILES/Delta_File.out");
// ////if (X[i] == 1)
// ////{
// //// SandOut_File_s.Write(Environment.NewLine);
// //// Delta_File.Write(Environment.NewLine);
// ////}
// //Delta_File.Write(counter + " " + X[i] + " " + Y[i] + " " + DeltaArea + Environment.NewLine);
// //Delta_File.Close();
// SandOut_File_s.Write(counter + " " + DirectionAcrossBorder[i] + " " + X[i] + " " + Y[i] + " " + (VolumeIn[i] / (CellWidth * CellWidth)) + " " + (VolumeOut[i] / (CellWidth * CellWidth)) + " " + DeltaArea + " " + VolumeAcrossBorder[i] + " " + ActualVolumeAcross[i] + Environment.NewLine);
// SandOut_File_s.Close();
// hit = 1;
//}
if (HaveSinks == 1)
{
for (int Sx = 0; Sx < SinkX.Length; Sx++)
{
if (X[i] == SinkX[Sx])
{
DeltaArea = 0;
}
}
}
int CellCount = 0;
double firstDeltaArea;
double A2; // End Amount
double P2; // Start Amount
double t2;
double A3; // End Amount
double P3; // Start Amount
double t3; // time
double decayRate1;
double averageChange = Math.Abs(DeltaArea / MaxDist);
int shortShoreface = 10;
if (DeltaArea != 0)
{
// Delta Area > 0
//
if (DeltaArea > 0)
{
if (numCells[i] < shortShoreface)
{
//double firstDeltaArea = DeltaArea / numCells[i];
firstDeltaArea = DeltaArea / MaxDist;
A2 = Math.Abs(DeltaArea - firstDeltaArea); // End Amount
P2 = 1; // Start Amount
t2 = MaxDist;
}
else
{
firstDeltaArea = DeltaArea / numCells[i];
A2 = Math.Abs(DeltaArea - firstDeltaArea); // End Amount
P2 = 1; // Start Amount
t2 = numCells[i]; // time
}
if (numCells[i] <= 1)
{
numCells[i] = 2;
t2 = 1;
}
decayRate1 = (Math.Log(A2 / P2)) / t2; // r, decay rate
//double firstDeltaArea = DeltaArea * decayRate1;
int jj = 0;
if (AboveWater[X[i], Y[i]] == 1)
{
if (direction[i] == 1)
{
if (VolumeChange[X[i], Y[i] + 1] < averageChange && AboveWater[X[i], Y[i] + 1] == 0)
{
VolumeChange[X[i], Y[i] + 1] += firstDeltaArea;
}
}
else if (direction[i] == 2)
{
if (VolumeChange[X[i] + 1, Y[i] + 1] < averageChange && AboveWater[X[i] + 1, Y[i] + 1] == 0)
{
VolumeChange[X[i] + 1, Y[i] + 1] += firstDeltaArea;
}
}
else if (direction[i] == 3)
{
if (VolumeChange[X[i] + 1, Y[i]] < averageChange && AboveWater[X[i] + 1, Y[i]] == 0)
{
VolumeChange[X[i] + 1, Y[i]] += firstDeltaArea;
}
}
else if (direction[i] == 4)
{
if (VolumeChange[X[i] + 1, Y[i] - 1] < averageChange && AboveWater[X[i] + 1, Y[i] - 1] == 0)
{
VolumeChange[X[i] + 1, Y[i] - 1] += firstDeltaArea;
}
}
else if (direction[i] == 5)
{
if (VolumeChange[X[i], Y[i] - 1] < averageChange && AboveWater[X[i], Y[i] - 1] == 0)
{
VolumeChange[X[i], Y[i] - 1] += firstDeltaArea;
}
}
else if (direction[i] == 6)
{
if (VolumeChange[X[i] - 1, Y[i] - 1] < averageChange && AboveWater[X[i] - 1, Y[i] - 1] == 0)
{
VolumeChange[X[i] - 1, Y[i] - 1] += firstDeltaArea;
}
}
else if (direction[i] == 7)
{
if (VolumeChange[X[i] - 1, Y[i]] < averageChange && AboveWater[X[i] - 1, Y[i]] == 0)
{
VolumeChange[X[i] - 1, Y[i]] += firstDeltaArea;
}
}
else if (direction[i] == 8)
{
if (VolumeChange[X[i] - 1, Y[i] + 1] < averageChange && AboveWater[X[i] - 1, Y[i] + 1] == 0)
{
VolumeChange[X[i] - 1, Y[i] + 1] += firstDeltaArea;
}
}
numCells[i]--;
jj = 2;
}
else
{
if (VolumeChange[X[i], Y[i]] < averageChange && AboveWater[X[i], Y[i]] == 0)
{
VolumeChange[X[i], Y[i]] += firstDeltaArea;
}
numCells[i]--;
jj = 1;
}
int xHolder;
int s = 0;
double extraDeltaArea = DeltaArea - firstDeltaArea; // How much material do we have?
double totalDeltaArea = DeltaArea - firstDeltaArea; // Keep tracks of little bits that are left.
double A = DeltaArea - firstDeltaArea; // End Amount
double P = 1; // Start Amount
double t;
if (numCells[i] < shortShoreface)
{
t = MaxDist - jj; // time
}
else
{
t = numCells[i] - jj;
}
double decayRate = (Math.Log(A / P)) / t; // r, decay rate
if (direction[i] == 1) // Up
{
for (int j = jj; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
//if (j == numCells[i] - 1 && AboveWater[X[i], Y[i] + j] == 0)
//{
// VolumeChange[X[i], Y[i] + j] += totalDeltaArea;
//}
if (Y[i] + j >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] + j] == 0 && VolumeChange[X[i], Y[i] + j] < averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] + j] += totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] + j] += extraDeltaArea;
}
}
totalDeltaArea -= extraDeltaArea;
}
}
else if (direction[i] == 3) // Right
{
xHolder = X[i];
for (int j = jj; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
if (xHolder + s > pbEnd - 1)
{
xHolder = 0;
s = 0;
}
else if (AboveWater[xHolder + s, Y[i]] == 0 && VolumeChange[xHolder + s, Y[i]] < averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[xHolder + s, Y[i]] += totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[xHolder + s, Y[i]] += extraDeltaArea;
}
s++;
}
totalDeltaArea -= extraDeltaArea;
}
// Turn direction to up
// Share rest with north going cells, along all X-numcells
if (totalDeltaArea > 0)
{
int k = 1;
//int n = 0;
// while (totalDeltaArea > 0)
// {
// for (int m = 0; m < numCells[i] && totalDeltaArea > 0; m++)
// {
// extraDeltaArea = totalDeltaArea * decayRate;
// if (Y[i] + k >= ymax)
// {
// lost += totalDeltaArea;
// totalDeltaArea = 0;
// break;
// }
// else if (xHolder + n > pbEnd - 1)
// {
// xHolder = 0;
// n = 0;
// }
// if (AboveWater[xHolder + n, Y[i] + k] == 0 && VolumeChange[xHolder + n, Y[i] + k] < averageChange)
// {
// if (totalDeltaArea < extraDeltaArea)
// {
// VolumeChange[xHolder + n, Y[i] + k] += totalDeltaArea;
// }
// else
// {
// VolumeChange[xHolder + n, Y[i] + k] += extraDeltaArea;
// }
// }
// totalDeltaArea -= extraDeltaArea;
// n++;
// }
// n = 0;
// xHolder = X[i];
// k++;
// }
for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
//if (Y[i] + k < ymax && AboveWater[X[i], Y[i] + k] == 0)
//{
//if (j == MaxDist - 1)
//{
// VolumeChange[X[i], Y[i] + k] += totalDeltaArea;
//}
if (Y[i] + k >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] < averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] + k] += totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] + k] += extraDeltaArea;
}
}
k++;
totalDeltaArea -= extraDeltaArea;
//}
//else
//{
// totalDeltaArea = 0;
// break;
//}
}
}
}
else if (direction[i] == 5) // Bottom
{
for (int j = jj; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
//if (j == numCells[i] - 1 && AboveWater[X[i], Y[i] - j] == 0)
//{
// VolumeChange[X[i], Y[i] - j] += totalDeltaArea;
//}
if (Y[i] - j >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] - j] == 0 && VolumeChange[X[i], Y[i] - j] < averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] - j] += totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] - j] += extraDeltaArea;
}
}
totalDeltaArea -= extraDeltaArea;
}
}
else if (direction[i] == 7) // Left
{
xHolder = X[i];
for (int j = jj; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
if (xHolder - s < 0)
{
xHolder = pbEnd - 1;
s = 0;
}
//if (j == numCells[i] - 1)
//{
// VolumeChange[xHolder - s, Y[i]] += totalDeltaArea;
//}
else if (AboveWater[xHolder - s, Y[i]] == 0 && VolumeChange[xHolder - s, Y[i]] < averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[xHolder - s, Y[i]] += totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[xHolder - s, Y[i]] += extraDeltaArea;
}
s++;
}
totalDeltaArea -= extraDeltaArea;
}
//// Turn direction to up
//// Share rest with north going cells, along all X-numcells
//if (totalDeltaArea > 0)
//{
// int k = 1;
// int n = 0;
// while (totalDeltaArea > 0)
// {
// for (int m = 0; m < numCells[i] && totalDeltaArea > 0; m++)
// {
// extraDeltaArea = totalDeltaArea * decayRate;
// if (Y[i] + k >= ymax)
// {
// lost += totalDeltaArea;
// totalDeltaArea = 0;
// break;
// }
// else if (xHolder - n < 0)
// {
// xHolder = pbEnd - 1;
// n = 0;
// }
// if (AboveWater[xHolder - n, Y[i] + k] == 0 && VolumeChange[xHolder - n, Y[i] + k] < averageChange)
// {
// if (totalDeltaArea < extraDeltaArea)
// {
// VolumeChange[xHolder - n, Y[i] + k] += totalDeltaArea;
// }
// else
// {
// VolumeChange[xHolder - n, Y[i] + k] += extraDeltaArea;
// }
// }
// totalDeltaArea -= extraDeltaArea;
// n++;
// }
// n = 0;
// xHolder = X[i];
// k++;
// }
if (totalDeltaArea > 0)
{
// Turn direction to up
int k = 1;
for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
//if (Y[i] + k < ymax && AboveWater[X[i], Y[i] + k] == 0)
//{
//if (j == MaxDist - 1)
//{
// VolumeChange[X[i], Y[i] + k] += totalDeltaArea;
//}
if (Y[i] + k >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] < averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] + k] = +totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] + k] += extraDeltaArea;
}
}
k++;
totalDeltaArea -= extraDeltaArea;
//}
//else
//{
// totalDeltaArea = 0;
// break;
//}
}
}
}
}
//
// Delta Area < 0
//
else if (DeltaArea < 0)
{
averageChange = averageChange * -1;
if (numCells[i] < shortShoreface)
{
//double firstDeltaArea = DeltaArea / numCells[i];
firstDeltaArea = DeltaArea / MaxDist;
A3 = Math.Abs(DeltaArea - firstDeltaArea); // End Amount
P3 = 1; // Start Amount
t3 = MaxDist;
}
else
{
firstDeltaArea = DeltaArea / numCells[i];
A3 = Math.Abs(DeltaArea - firstDeltaArea); // End Amount
P3 = 1; // Start Amount
t3 = numCells[i]; // time
}
if (numCells[i] <= 1)
{
numCells[i] = 2;
t3 = 1;
}
decayRate1 = (Math.Log(A3 / P3)) / t3; // r, decay rate
//double firstDeltaArea = DeltaArea * decayRate1; // /2 works with DeltaArea/100
if (VolumeChange[X[i], Y[i]] > averageChange)
{
VolumeChange[X[i], Y[i]] += firstDeltaArea;
}
numCells[i]--;
int xHolder;
int s = 0;
double extraDeltaArea = Math.Abs(DeltaArea - firstDeltaArea); // How much material do we have?
double totalDeltaArea = Math.Abs(DeltaArea - firstDeltaArea); // Keep tracks of little bits that are left.
double A = Math.Abs(DeltaArea - firstDeltaArea); // End Amount
double P = 1; // Start Amount
double t;
if (numCells[i] < shortShoreface)
{
t = MaxDist - 1; // time
}
else
{
t = numCells[i] - 1;
} // time
double decayRate = Math.Log(A / P) / t; // r, decay rate
if (direction[i] == 1) // Up
{
for (int j = 0; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
//if (j == numCells[i] - 1 && AboveWater[X[i], Y[i] + j] == 0)
//{
// VolumeChange[X[i], Y[i] + j] -= extraDeltaArea;
//}
if (Y[i] + j >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] + j] == 0 && VolumeChange[X[i], Y[i] + j] > averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] + j] -= totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] + j] -= extraDeltaArea;
}
}
totalDeltaArea -= extraDeltaArea;
}
}
else if (direction[i] == 3) // Right
{
xHolder = X[i];
for (int j = 0; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
if (xHolder + s > pbEnd - 1)
{
xHolder = 0;
s = 0;
}
//if (j == numCells[i] - 1)
//{
// VolumeChange[xHolder + s, Y[i]] -= totalDeltaArea;
// s++;
//}
else if (AboveWater[xHolder + s, Y[i]] == 0 && VolumeChange[xHolder + s, Y[i]] > averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[xHolder + s, Y[i]] -= totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[xHolder + s, Y[i]] -= extraDeltaArea;
}
s++;
}
totalDeltaArea -= extraDeltaArea;
}
//if (totalDeltaArea > 0)
//{
// int k = 1;
// int n = 0;
// while (totalDeltaArea > 0)
// {
// for (int m = 0; m < numCells[i] && totalDeltaArea > 0; m++)
// {
// extraDeltaArea = totalDeltaArea * decayRate;
// if (Y[i] + k >= ymax)
// {
// lost += totalDeltaArea;
// totalDeltaArea = 0;
// break;
// }
// else if (xHolder + n > pbEnd - 1)
// {
// xHolder = 0;
// n = 0;
// }
// if (AboveWater[xHolder + n, Y[i] + k] == 0 && VolumeChange[xHolder + n, Y[i] + k] < averageChange)
// {
// if (totalDeltaArea < extraDeltaArea)
// {
// VolumeChange[xHolder + n, Y[i] + k] -= totalDeltaArea;
// }
// else
// {
// VolumeChange[xHolder + n, Y[i] + k] -= extraDeltaArea;
// }
// }
// totalDeltaArea -= extraDeltaArea;
// n++;
// }
// n = 0;
// xHolder = X[i];
// k++;
// }
//}
if (totalDeltaArea > 0)
{
// Turn direction to up
int k = 1;
for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
//if (Y[i] + k < ymax && AboveWater[X[i], Y[i] + k] == 0)
//{
//if (j == MaxDist - 1)
//{
// VolumeChange[X[i], Y[i] + k] += totalDeltaArea;
//}
if (Y[i] + k >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] > averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] + k] -= totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] + k] -= extraDeltaArea;
}
}
k++;
totalDeltaArea -= extraDeltaArea;
//}
//else
//{
// totalDeltaArea = 0;
// break;
//}
}
}
}
else if (direction[i] == 5) // Bottom
{
for (int j = 0; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
//if (j == numCells[i] - 1 && AboveWater[X[i], Y[i] - j] == 0)
//{
// VolumeChange[X[i], Y[i] - j] -= totalDeltaArea;
//}
if (Y[i] - j >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] - j] == 0 && VolumeChange[X[i], Y[i] - j] > averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] - j] -= totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] - j] -= extraDeltaArea;
}
}
totalDeltaArea -= extraDeltaArea;
}
}
else if (direction[i] == 7) // Left
{
xHolder = X[i];
for (int j = 0; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
if (xHolder - s < 0)
{
xHolder = pbEnd - 1;
s = 0;
}
//if (j == numCells[i] - 1)
//{
// VolumeChange[xHolder - s, Y[i]] -= totalDeltaArea;
//}
else if (AboveWater[xHolder - s, Y[i]] == 0 && VolumeChange[xHolder - s, Y[i]] > averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[xHolder - s, Y[i]] -= totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[xHolder - s, Y[i]] -= extraDeltaArea;
}
s++;
}
totalDeltaArea -= extraDeltaArea;
}
//// Turn direction to up
//// Share rest with north going cells, along all X-numcells
//if (totalDeltaArea > 0)
//{
// int k = 1;
// int n = 0;
// while (totalDeltaArea > 0)
// {
// for (int m = 0; m < numCells[i] && totalDeltaArea > 0; m++)
// {
// extraDeltaArea = totalDeltaArea * decayRate;
// if (Y[i] + k >= ymax)
// {
// lost += totalDeltaArea;
// totalDeltaArea = 0;
// break;
// }
// else if (xHolder - n < 0)
// {
// xHolder = pbEnd - 1;
// n = 0;
// }
// if (AboveWater[xHolder - n, Y[i] + k] == 0 && VolumeChange[xHolder - n, Y[i] + k] < averageChange)
// {
// if (totalDeltaArea < extraDeltaArea)
// {
// VolumeChange[xHolder - n, Y[i] + k] -= totalDeltaArea;
// }
// else
// {
// VolumeChange[xHolder - n, Y[i] + k] -= extraDeltaArea;
// }
// }
// totalDeltaArea -= extraDeltaArea;
// n++;
// }
// n = 0;
// xHolder = X[i];
// k++;
// }
//}
if (totalDeltaArea > 0)
{
// Turn direction to up
int k = 1;
for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
{
extraDeltaArea = totalDeltaArea * decayRate;
//if (Y[i] + k < ymax && AboveWater[X[i], Y[i] + k] == 0)
//{
//if (j == MaxDist - 1)
//{
// VolumeChange[X[i], Y[i] + k] += totalDeltaArea;
//}
if (Y[i] + k >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] > averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] + k] -= totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] + k] -= extraDeltaArea;
}
}
k++;
totalDeltaArea -= extraDeltaArea;
//}
//else
//{
// totalDeltaArea = 0;
// break;
//}
}
}
}
}
}
//BlockTooBig:
// DeltaArea = 0;
}
void AdjustShore_reducePertcent1(int i)
{
// Complete mass balance for incoming and ougoing sediment
// This function will change the global data array PercentFullSand[][]
// Uses but does not adjust arrays: X[], Y[], ShorelineAngle[], ActualVolumeAcross LMV
// Uses global variables: ShelfSlope, CellWidth, ShorefaceSlope, InitialDepth
//FIND EFFECTIVE DEPTH, Deff, HERE
//Deff = FROM SOLUTION TO:
//A*Distance^n = D(X) - OverallSlope*cos(ShorelineAngle[X][Y])*Distance
//Where Distance is from shore, perpendicular to ShorelineAngle;
//Brad's stuff not being used right now (linear slope for now) :
//Xintercept = X + Distance*cos(ShorelineAngle), and n = 2/3.
//THEN Deff = D(Xintercept);
//FIND "A" FROM DEPTH OF 10METERS AT ABOUT 1000METERS.
//FOR NOW, USE n = 1:
double DeltaArea; // Holds change in area for cell (m^2)
if (FlowThroughCell[i] == 'L')
{
VolumeIn[i] = ActualVolumeAcross[i];
VolumeOut[i] = ActualVolumeAcross[i - 1];
}
if (FlowThroughCell[i] == 'C')
{
VolumeIn[i] = ActualVolumeAcross[i];
VolumeOut[i] = -ActualVolumeAcross[i - 1];
}
if (FlowThroughCell[i] == 'D')
{
VolumeIn[i] = -ActualVolumeAcross[i - 1];
VolumeOut[i] = ActualVolumeAcross[i];
}
if (FlowThroughCell[i] == 'R')
{
VolumeIn[i] = ActualVolumeAcross[i - 1];
VolumeOut[i] = ActualVolumeAcross[i];
}
DeltaArea = ((VolumeIn[i] - VolumeOut[i]) / (CellWidth * CellWidth)) / 100;
if (X[i] == 1000 && Y[i] > 250 && hit == 0)
{
StreamWriter SandOut_File_s = File.AppendText("OUTPUT_FILES/SandOut_start.out");
SandOut_File_s.Write(counter + " " + DirectionAcrossBorder[i] + " " + X[i] + " " + Y[i] + " " + (VolumeIn[i] / (CellWidth * CellWidth)) + " " + (VolumeOut[i] / (CellWidth * CellWidth)) + " " + DeltaArea + " " + VolumeAcrossBorder[i] + " " + ActualVolumeAcross[i] + Environment.NewLine);
SandOut_File_s.Close();
hit = 1;
}
if (HaveSinks == 1)
{
for (int Sx = 0; Sx < SinkX.Length; Sx++)
{
if (X[i] == SinkX[Sx])
{
DeltaArea = 0;
}
}
}
int CellCount = 0;
double firstDeltaArea;
double A2; // End Amount
double P2; // Start Amount
double t2;
double A3; // End Amount
double P3; // Start Amount
double t3; // time
double decayRate1;
double averageChange = 10;
int shortShoreface = 100;
if (DeltaArea != 0)
{
//
// Delta Area > 0
//
if (DeltaArea > 0)
{
firstDeltaArea = DeltaArea / 80; // Give 20% to the first cell
if (numCells[i] <= 1)
{
numCells[i] = 2;
}
int jj = 0;
if (AboveWater[X[i], Y[i]] == 1)
{
if (direction[i] == 1)
{
if (VolumeChange[X[i], Y[i] + 1] < averageChange && AboveWater[X[i], Y[i] + 1] == 0)
{
VolumeChange[X[i], Y[i] + 1] += firstDeltaArea;
}
}
else if (direction[i] == 2)
{
if (VolumeChange[X[i] + 1, Y[i] + 1] < averageChange && AboveWater[X[i] + 1, Y[i] + 1] == 0)
{
VolumeChange[X[i] + 1, Y[i] + 1] += firstDeltaArea;
}
}
else if (direction[i] == 3)
{
if (VolumeChange[X[i] + 1, Y[i]] < averageChange && AboveWater[X[i] + 1, Y[i]] == 0)
{
VolumeChange[X[i] + 1, Y[i]] += firstDeltaArea;
}
}
else if (direction[i] == 4)
{
if (VolumeChange[X[i] + 1, Y[i] - 1] < averageChange && AboveWater[X[i] + 1, Y[i] - 1] == 0)
{
VolumeChange[X[i] + 1, Y[i] - 1] += firstDeltaArea;
}
}
else if (direction[i] == 5)
{
if (VolumeChange[X[i], Y[i] - 1] < averageChange && AboveWater[X[i], Y[i] - 1] == 0)
{
VolumeChange[X[i], Y[i] - 1] += firstDeltaArea;
}
}
else if (direction[i] == 6)
{
if (VolumeChange[X[i] - 1, Y[i] - 1] < averageChange && AboveWater[X[i] - 1, Y[i] - 1] == 0)
{
VolumeChange[X[i] - 1, Y[i] - 1] += firstDeltaArea;
}
}
else if (direction[i] == 7)
{
if (VolumeChange[X[i] - 1, Y[i]] < averageChange && AboveWater[X[i] - 1, Y[i]] == 0)
{
VolumeChange[X[i] - 1, Y[i]] += firstDeltaArea;
}
}
else if (direction[i] == 8)
{
if (VolumeChange[X[i] - 1, Y[i] + 1] < averageChange && AboveWater[X[i] - 1, Y[i] + 1] == 0)
{
VolumeChange[X[i] - 1, Y[i] + 1] += firstDeltaArea;
}
}
numCells[i]--;
jj = 2;
}
else
{
if (VolumeChange[X[i], Y[i]] < averageChange && AboveWater[X[i], Y[i]] == 0)
{
VolumeChange[X[i], Y[i]] += firstDeltaArea;
}
numCells[i]--;
jj = 1;
}
int xHolder;
int s = 0;
double extraDeltaArea = DeltaArea - firstDeltaArea; // How much material do we have?
double totalDeltaArea = DeltaArea - firstDeltaArea; // Keep tracks of little bits that are left.
double A = DeltaArea - firstDeltaArea; // End Amount
double P = 1; // Start Amount
double t;
if (numCells[i] < shortShoreface)
{
t = MaxDist - jj; // time
}
else
{
t = numCells[i] - jj;
}
double decayRate = firstDeltaArea / 20; // r, decay rate
double previousDA = firstDeltaArea;
if (direction[i] == 1) // Up
{
for (int j = jj; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = previousDA - decayRate;
if (Y[i] + j >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] + j] == 0 && VolumeChange[X[i], Y[i] + j] < averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] + j] += totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] + j] += extraDeltaArea;
}
}
totalDeltaArea -= extraDeltaArea;
previousDA = extraDeltaArea;
}
}
else if (direction[i] == 3) // Right
{
xHolder = X[i];
for (int j = jj; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = previousDA - decayRate;
if (xHolder + s > pbEnd - 1)
{
xHolder = 0;
s = 0;
}
else if (AboveWater[xHolder + s, Y[i]] == 0 && VolumeChange[xHolder + s, Y[i]] < averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[xHolder + s, Y[i]] += totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[xHolder + s, Y[i]] += extraDeltaArea;
}
s++;
}
totalDeltaArea -= extraDeltaArea;
previousDA = extraDeltaArea;
}
// Turn direction to up
// Share rest with north going cells, along all X-numcells
if (totalDeltaArea > 0)
{
int k = 1;
for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
{
extraDeltaArea = previousDA - decayRate;
if (Y[i] + k >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] < averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] + k] += totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] + k] += extraDeltaArea;
}
}
k++;
totalDeltaArea -= extraDeltaArea;
previousDA = extraDeltaArea;
}
}
}
else if (direction[i] == 5) // Bottom
{
for (int j = jj; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = previousDA - decayRate;
if (Y[i] - j >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] - j] == 0 && VolumeChange[X[i], Y[i] - j] < averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] - j] += totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] - j] += extraDeltaArea;
}
}
totalDeltaArea -= extraDeltaArea;
previousDA = extraDeltaArea;
}
}
else if (direction[i] == 7) // Left
{
xHolder = X[i];
for (int j = jj; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = previousDA - decayRate;
if (xHolder - s < 0)
{
xHolder = pbEnd - 1;
s = 0;
}
else if (AboveWater[xHolder - s, Y[i]] == 0 && VolumeChange[xHolder - s, Y[i]] < averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[xHolder - s, Y[i]] += totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[xHolder - s, Y[i]] += extraDeltaArea;
}
s++;
}
totalDeltaArea -= extraDeltaArea;
previousDA = extraDeltaArea;
}
if (totalDeltaArea > 0)
{
// Turn direction to up
int k = 1;
for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
{
extraDeltaArea = previousDA - decayRate;
if (Y[i] + k >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] < averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] + k] += totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] + k] += extraDeltaArea;
}
}
k++;
totalDeltaArea -= extraDeltaArea;
previousDA = extraDeltaArea;
}
}
}
}
//
// Delta Area < 0
//
else if (DeltaArea < 0)
{
averageChange = averageChange * -1;
firstDeltaArea = DeltaArea / 80; // Give 20% to the first cell
if (numCells[i] <= 1)
{
numCells[i] = 2;
}
if (VolumeChange[X[i], Y[i]] > averageChange)
{
VolumeChange[X[i], Y[i]] += firstDeltaArea;
}
numCells[i]--;
int xHolder;
int s = 0;
double extraDeltaArea = Math.Abs(DeltaArea + firstDeltaArea); // How much material do we have?
double totalDeltaArea = Math.Abs(DeltaArea + firstDeltaArea); // Keep tracks of little bits that are left.
double A = Math.Abs(DeltaArea + firstDeltaArea); // End Amount
double P = 1; // Start Amount
double t;
if (numCells[i] < shortShoreface)
{
t = MaxDist - 1; // time
}
else
{
t = numCells[i] - 1;
} // time
double decayRate = Math.Abs(firstDeltaArea / 20); // r, decay rate
double previousDA = Math.Abs(firstDeltaArea);
if (direction[i] == 1) // Up
{
for (int j = 0; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = previousDA - decayRate;
if (Y[i] + j >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] + j] == 0 && VolumeChange[X[i], Y[i] + j] > averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] + j] -= totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] + j] -= extraDeltaArea;
}
}
totalDeltaArea -= extraDeltaArea;
previousDA = extraDeltaArea;
}
}
else if (direction[i] == 3) // Right
{
xHolder = X[i];
for (int j = 0; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = previousDA - decayRate;
if (xHolder + s > pbEnd - 1)
{
xHolder = 0;
s = 0;
}
else if (AboveWater[xHolder + s, Y[i]] == 0 && VolumeChange[xHolder + s, Y[i]] > averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[xHolder + s, Y[i]] -= totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[xHolder + s, Y[i]] -= extraDeltaArea;
}
s++;
}
totalDeltaArea -= extraDeltaArea;
previousDA = extraDeltaArea;
}
if (totalDeltaArea > 0)
{
// Turn direction to up
int k = 1;
for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
{
extraDeltaArea = previousDA - decayRate;
if (Y[i] + k >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] > averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] + k] -= totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] + k] -= extraDeltaArea;
}
}
k++;
totalDeltaArea -= extraDeltaArea;
previousDA = extraDeltaArea;
}
}
}
else if (direction[i] == 5) // Bottom
{
for (int j = 0; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = previousDA - decayRate;
if (Y[i] - j >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] - j] == 0 && VolumeChange[X[i], Y[i] - j] > averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] - j] -= totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] - j] -= extraDeltaArea;
}
}
totalDeltaArea -= extraDeltaArea;
previousDA = extraDeltaArea;
}
}
else if (direction[i] == 7) // Left
{
xHolder = X[i];
for (int j = 0; j < numCells[i] && totalDeltaArea > 0; j++)
{
extraDeltaArea = previousDA - decayRate;
if (xHolder - s < 0)
{
xHolder = pbEnd - 1;
s = 0;
}
else if (AboveWater[xHolder - s, Y[i]] == 0 && VolumeChange[xHolder - s, Y[i]] > averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[xHolder - s, Y[i]] -= totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[xHolder - s, Y[i]] -= extraDeltaArea;
}
s++;
}
totalDeltaArea -= extraDeltaArea;
previousDA = extraDeltaArea;
}
if (totalDeltaArea > 0)
{
// Turn direction to up
int k = 1;
for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
{
extraDeltaArea = previousDA - decayRate;
if (Y[i] + k >= ymax)
{
lost += totalDeltaArea;
totalDeltaArea = 0;
}
else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] > averageChange)
{
if (totalDeltaArea < extraDeltaArea)
{
VolumeChange[X[i], Y[i] + k] -= totalDeltaArea;
totalDeltaArea = 0;
extraDeltaArea = 0;
}
else
{
VolumeChange[X[i], Y[i] + k] -= extraDeltaArea;
}
}
k++;
totalDeltaArea -= extraDeltaArea;
previousDA = extraDeltaArea;
}
}
}
}
}
}
void AdjustShore(int i)
{
// Complete mass balance for incoming and ougoing sediment
// This function will change the global data array PercentFullSand[][]
// Uses but does not adjust arrays: X[], Y[], ShorelineAngle[], ActualVolumeAcross LMV
// Uses global variables: ShelfSlope, CellWidth, ShorefaceSlope, InitialDepth
//FIND EFFECTIVE DEPTH, Deff, HERE
//Deff = FROM SOLUTION TO:
//A*Distance^n = D(X) - OverallSlope*cos(ShorelineAngle[X][Y])*Distance
//Where Distance is from shore, perpendicular to ShorelineAngle;
//Brad's stuff not being used right now (linear slope for now) :
//Xintercept = X + Distance*cos(ShorelineAngle), and n = 2/3.
//THEN Deff = D(Xintercept);
//FIND "A" FROM DEPTH OF 10METERS AT ABOUT 1000METERS.
//FOR NOW, USE n = 1:
//// DEBUGGING START
//if (counter == 365 &&((i == 88) || (i == 89) || (i == 90) || (i == 91) || (i == 92) || (i == 93) || (i == 94) || (i == 95) || (i == 96) || (i == 97) || (i == 98) || (i == 99) || (i == 100)))
//{
// Array.Clear(VolumeChange, 0, VolumeChange.Length);
//}
//// DEBUGGIN END
double DeltaArea; // Holds change in area for cell (m^2)
if (i == 0)
{
//if (FlowThroughCell[i] == 'L')
//{
// VolumeIn[i] = ActualVolumeAcross[i];
// VolumeOut[i] = ActualVolumeAcross[TotalBeachCells - 1];
//}
//else if (FlowThroughCell[i] == 'C')
//{
// VolumeIn[i] = ActualVolumeAcross[i];
// VolumeOut[i] = -ActualVolumeAcross[TotalBeachCells - 1];
//}
//else if (FlowThroughCell[i] == 'D')
//{
// VolumeIn[i] = -ActualVolumeAcross[TotalBeachCells - 1];
// VolumeOut[i] = ActualVolumeAcross[i];
//}
//else if (FlowThroughCell[i] == 'R')
//{
// VolumeIn[i] = ActualVolumeAcross[TotalBeachCells - 1];
// VolumeOut[i] = ActualVolumeAcross[i];
//}
//else
//{
//}
}
else
{
if (FlowThroughCell[i] == 'L')
{
VolumeIn[i] = ActualVolumeAcross[i];
VolumeOut[i] = ActualVolumeAcross[i - 1];
}
else if (FlowThroughCell[i] == 'C')
{
VolumeIn[i] = ActualVolumeAcross[i];
VolumeOut[i] = -ActualVolumeAcross[i - 1];
}
else if (FlowThroughCell[i] == 'D')
{
VolumeIn[i] = -ActualVolumeAcross[i - 1];
VolumeOut[i] = ActualVolumeAcross[i];
}
else if (FlowThroughCell[i] == 'R')
{
VolumeIn[i] = ActualVolumeAcross[i - 1];
VolumeOut[i] = ActualVolumeAcross[i];
}
else
{
if (counter == 0)
{
FlowZeroCount = 0;
}
else if (counter == 1)
{
FlowZeroCount++;
}
}
}
DeltaArea = ((VolumeIn[i] - VolumeOut[i]) / (CellWidth * CellWidth));
VolumeChange[X[i], Y[i]] += DeltaArea;
// Save results data
if (counter % Resuldata_freq == 0 && i == pbEnd - 2)
{
string filelocation_results;
if (autorestart == 1)
{
Directory.CreateDirectory("OUTPUT_FILES/Run_" + Restart_count + "/Results");
filelocation_results = "OUTPUT_FILES/Run_" + Restart_count + "/Results/";
}
else
{
Directory.CreateDirectory("OUTPUT_FILES/Results");
filelocation_results = "OUTPUT_FILES/Results/";
}
if (counter == 0)
{
StreamWriter Delta_Area = new StreamWriter(filelocation_results + "DeltaArea.out");
Delta_Area.WriteLine(counter + " " + i + " " + DeltaArea + " Counter i DeltaArea");
Delta_Area.Close();
}
else
{
StreamWriter Delta_Area = File.AppendText(filelocation_results + "DeltaArea.out");
Delta_Area.WriteLine(counter + " " + i + " " + DeltaArea);
Delta_Area.Close();
}
}
//// DEBUGGING START
//if (counter == 365 && ((i == 88) || (i == 89) || (i == 90) || (i == 91) || (i == 92) || (i == 93) || (i == 94) || (i == 95) || (i == 96) || (i == 97) || (i == 98) || (i == 99) || (i == 100)))
//{
// StreamWriter DEBUG_FILE_DELTA = File.AppendText("OUTPUT_FILES/DEBUG_FILE_DELTA_" + i + ".out");
// DEBUG_FILE_DELTA.Write(counter + " " + i + " " + X[i] + " " + Y[i] + " " + DeltaArea + " " + VolumeIn[i] + " " + VolumeOut[i] + " " + VolumeAcrossBorder[i] + " " + ActualVolumeAcross[i] + Environment.NewLine);
// DEBUG_FILE_DELTA.Close();
//}
//// DEBUGGING END
////if (DeltaArea > 0)
////{
//// VolumeChange[X[i], Y[i] + 1] += DeltaArea;
////}
////else
////{
//// VolumeChange[X[i], Y[i]] += DeltaArea;
////}
////int a = 0;
////double TotalDelta = Math.Abs(DeltaArea);
////double DeltaChange = TotalDelta / 10;
////if (DeltaArea < 0)
////{
//// while (TotalDelta > 0)
//// {
//// if (DeltaChange < TotalDelta)
//// {
//// VolumeChange[X[i], Y[i] + a] -= TotalDelta;
//// a++;
//// TotalDelta = 0;
//// DeltaChange = 0;
//// }
//// else
//// {
//// VolumeChange[X[i], Y[i] + a] -= DeltaChange;
//// a++;
//// }
//// TotalDelta -= DeltaChange;
//// }
////}
////else if (DeltaArea > 0)
////{
//// while (TotalDelta > 0)
//// {
//// if (DeltaChange < TotalDelta)
//// {
//// a++;
//// VolumeChange[X[i], Y[i] + a] += TotalDelta;
//// TotalDelta = 0;
//// DeltaChange = 0;
//// }
//// else
//// {
//// a++;
//// VolumeChange[X[i], Y[i] + a] += DeltaArea;
//// }
//// TotalDelta -= DeltaChange;
//// }
////}
////_____________________________//
////StreamWriter delta = File.AppendText("OUTPUT_FILES/delta.out");
////delta.Write(counter + " " + DeltaArea + Environment.NewLine);
////delta.Close();
///////
/////// PRINT FILES
///////
////if (counter >= 10220)
////{
// //if (X[i] == 800 && hit == 0)
// //{
// //StreamWriter SandOut_File_s = File.AppendText("OUTPUT_FILES/SandOut_start.out");
// //SandOut_File_s.Write(counter + " " + DirectionAcrossBorder[i] + " " + X[i] + " " + Y[i] + " " + (VolumeIn[i] / (CellWidth * CellWidth)) + " " + (VolumeOut[i] / (CellWidth * CellWidth)) + " " + DeltaArea + " " + VolumeAcrossBorder[i] + " " + ActualVolumeAcross[i] + Environment.NewLine);
// //SandOut_File_s.Close();
// //hit = 1;
// //}
////}
///////
/////// Sinks
///////
////if (HaveSinks == 1)
////{
//// for (int Sx = 0; Sx < SinkX.Length; Sx++)
//// {
//// if (X[i] == SinkX[Sx])
//// {
//// DeltaArea = 0;
//// }
//// }
////}
//int CellCount = 0;
//double firstDeltaArea;
//double A2; // End Amount
//double P2; // Start Amount
//double t2;
//double A3; // End Amount
//double P3; // Start Amount
//double t3; // time
//double decayRate1;
//double averageChange = 100;
//int shortShoreface = 5;
//int sidewaysLimit = 5;
/////
///// If there is material to move...
/////
//double firstpercent = 0.01;
//double UPpercent = 0.01;
//double LRPercent = UPpercent/2;
//if (DeltaArea != 0)
//{
// ///
// /// Delta Area > 0
// ///
// if (DeltaArea > 0)
// {
// firstDeltaArea = ((DeltaArea * firstpercent)); // Give X% to the first cell
// if (numCells[i] <= 1)
// {
// numCells[i] = 2;
// }
// int jj = 0;
// if (AboveWater[X[i], Y[i]] == 1)
// {
// if (direction[i] == 1)
// {
// if (VolumeChange[X[i], Y[i] + 1] < averageChange && AboveWater[X[i], Y[i] + 1] == 0)
// {
// VolumeChange[X[i], Y[i] + 1] += firstDeltaArea;
// }
// }
// //else if (direction[i] == 2)
// //{
// // if (VolumeChange[X[i] + 1, Y[i] + 1] < averageChange && AboveWater[X[i] + 1, Y[i] + 1] == 0)
// // {
// // VolumeChange[X[i] + 1, Y[i] + 1] += firstDeltaArea;
// // }
// //}
// else if (direction[i] == 3)
// {
// if (VolumeChange[X[i] + 1, Y[i]] < averageChange && AboveWater[X[i] + 1, Y[i]] == 0)
// {
// VolumeChange[X[i] + 1, Y[i]] += firstDeltaArea;
// }
// }
// //else if (direction[i] == 4)
// //{
// // if (VolumeChange[X[i] + 1, Y[i] - 1] < averageChange && AboveWater[X[i] + 1, Y[i] - 1] == 0)
// // {
// // VolumeChange[X[i] + 1, Y[i] - 1] += firstDeltaArea;
// // }
// //}
// else if (direction[i] == 5)
// {
// if (VolumeChange[X[i], Y[i] - 1] < averageChange && AboveWater[X[i], Y[i] - 1] == 0)
// {
// VolumeChange[X[i], Y[i] - 1] += firstDeltaArea;
// }
// }
// //else if (direction[i] == 6)
// //{
// // if (VolumeChange[X[i] - 1, Y[i] - 1] < averageChange && AboveWater[X[i] - 1, Y[i] - 1] == 0)
// // {
// // VolumeChange[X[i] - 1, Y[i] - 1] += firstDeltaArea;
// // }
// //}
// else if (direction[i] == 7)
// {
// if (VolumeChange[X[i] - 1, Y[i]] < averageChange && AboveWater[X[i] - 1, Y[i]] == 0)
// {
// VolumeChange[X[i] - 1, Y[i]] += firstDeltaArea;
// }
// }
// //else if (direction[i] == 8)
// //{
// // if (VolumeChange[X[i] - 1, Y[i] + 1] < averageChange && AboveWater[X[i] - 1, Y[i] + 1] == 0)
// // {
// // VolumeChange[X[i] - 1, Y[i] + 1] += firstDeltaArea;
// // }
// //}
// numCells[i]--;
// jj = 2;
// }
// else
// {
// if (VolumeChange[X[i], Y[i]] < averageChange && AboveWater[X[i], Y[i]] == 0)
// {
// VolumeChange[X[i], Y[i]] += firstDeltaArea;
// }
// //numCells[i]--;
// jj = 1;
// }
// int xHolder;
// int s = jj;
// double extraDeltaArea = DeltaArea - firstDeltaArea; // How much material do we have?
// double totalDeltaArea = DeltaArea - firstDeltaArea; // Keep tracks of little bits that are left.
// double A = DeltaArea - firstDeltaArea; // End Amount
// double P = 1; // Start Amount
// double t;
// //if (numCells[i] < shortShoreface)
// //{
// // t = MaxDist - jj; // time
// //}
// //else
// //{
// t = numCells[i] - jj;
// //}
// double decayRate = firstDeltaArea * UPpercent; // r, decay rate
// double previousDA = firstDeltaArea;
// //if (direction[i] == 1) // Up
// //{
// // for (int j = jj; j < numCells[i] && totalDeltaArea > 0; j++)
// // {
// // extraDeltaArea = previousDA - decayRate;
// // if (Y[i] + j >= ymax)
// // {
// // lost += totalDeltaArea;
// // totalDeltaArea = 0;
// // }
// // else if (AboveWater[X[i], Y[i] + j] == 0 && VolumeChange[X[i], Y[i] + j] < averageChange)
// // {
// // if (totalDeltaArea < extraDeltaArea)
// // {
// // VolumeChange[X[i], Y[i] + j] += totalDeltaArea;
// // totalDeltaArea = 0;
// // extraDeltaArea = 0;
// // }
// // else
// // {
// // VolumeChange[X[i], Y[i] + j] += extraDeltaArea;
// // }
// // }
// // totalDeltaArea -= extraDeltaArea;
// // previousDA = extraDeltaArea;
// // }
// //}
// if (direction[i] == 1) // Up
// {
// xHolder = X[i];
// for (int j = jj; j < numCells[i] && totalDeltaArea > 0; j++)
// {
// extraDeltaArea = previousDA - decayRate;
// if (Y[i] + j >= ymax)
// {
// lost += totalDeltaArea;
// totalDeltaArea = 0;
// }
// else if (AboveWater[xHolder, Y[i] + j] == 0 && VolumeChange[xHolder, Y[i] + j] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder, Y[i] + j] += totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder, Y[i] + j] += decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder, Y[i] + j] += extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// s++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// // Turn direction right/left
// if (totalDeltaArea > 0)
// {
// // Go right
// if (WaveAngleIn > -90 && WaveAngleIn < 90)
// {
// int k = 1;
// for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// {
// extraDeltaArea = previousDA - (decayRate/2);
// if (xHolder + k > pbEnd - 1)
// {
// xHolder = 0;
// k = 0;
// }
// else if (AboveWater[xHolder + k, Y[i] + 1] == 0 && VolumeChange[xHolder + k, Y[i] + 1] < averageChange)
// {
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder + k, Y[i] + 1] += totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder + k, Y[i] + 1] += decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder + k, Y[i] + 1] += extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// }
// k++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// // go left
// else
// {
// int k = 1;
// for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// {
// extraDeltaArea = previousDA - (decayRate/2);
// if (xHolder - k < 0)
// {
// xHolder = 0;
// k = pbEnd - 1;
// }
// else if (AboveWater[xHolder - k, Y[i] + 1] == 0 && VolumeChange[xHolder - k, Y[i] + 1] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder - k, Y[i] + 1] += totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder - k, Y[i] + 1] += decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder - k, Y[i] + 1] += extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// }
// k++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// }
// }
// else if (direction[i] == 3) // Right
// {
// xHolder = X[i];
// for (int j = jj; ((j < numCells[i]) && (j < sidewaysLimit)) && totalDeltaArea > 0; j++)
// {
// ////extraDeltaArea = previousDA - decayRate;
// extraDeltaArea = previousDA - (decayRate/2);
// if (xHolder + s > pbEnd - 1)
// {
// xHolder = 0;
// s = 0;
// }
// ///
// else if (AboveWater[xHolder + s, Y[i]] == 0 && VolumeChange[xHolder + s, Y[i]] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder + s, Y[i]] += totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder + s, Y[i]] += decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder + s, Y[i]] += extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// s++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// // Turn direction to up
// // Share rest with north going cells, along all X-numcells
// if (totalDeltaArea > 0)
// {
// int k = 1;
// for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// {
// extraDeltaArea = previousDA - decayRate;
// if (Y[i] + k >= ymax)
// {
// lost += totalDeltaArea;
// totalDeltaArea = 0;
// }
// ///
// else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[X[i], Y[i] + k] += totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[X[i], Y[i] + k] += decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[X[i], Y[i] + k] += extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// }
// k++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// }
// else if (direction[i] == 5) // Bottom
// {
// xHolder = X[i];
// for (int j = jj; j < numCells[i] && totalDeltaArea > 0; j++)
// {
// extraDeltaArea = previousDA - decayRate;
// if (Y[i] - j >= ymax)
// {
// lost += totalDeltaArea;
// totalDeltaArea = 0;
// }
// else if (AboveWater[xHolder, Y[i] - j] == 0 && VolumeChange[xHolder, Y[i] - j] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder, Y[i] - j] += totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder, Y[i] - j] += decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder, Y[i] - j] += extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// s++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// // Turn direction right/left
// if (totalDeltaArea > 0)
// {
// if (WaveAngleIn > -90 && WaveAngleIn < 90) // Go right
// {
// int k = 1;
// for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// {
// ////extraDeltaArea = previousDA - decayRate;
// extraDeltaArea = previousDA - (decayRate/2);
// if (xHolder + k > pbEnd - 1)
// {
// xHolder = 0;
// k = 0;
// }
// else if (AboveWater[xHolder + k, Y[i] - 1] == 0 && VolumeChange[xHolder + k, Y[i] - 1] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder + k, Y[i] - 1] += totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder + k, Y[i] - 1] += decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder + k, Y[i] - 1] += extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// }
// k++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// else // go left
// {
// int k = 1;
// for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// {
// ////extraDeltaArea = previousDA - decayRate;
// extraDeltaArea = previousDA - (decayRate/2);
// if (xHolder - k < 0)
// {
// xHolder = 0;
// k = pbEnd - 1;
// }
// else if (AboveWater[xHolder - k, Y[i] - 1] == 0 && VolumeChange[xHolder - k, Y[i] - 1] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder - k, Y[i] - 1] += totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder - k, Y[i] - 1] += decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder - k, Y[i] - 1] += extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// }
// k++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// }
// }
// else if (direction[i] == 7) // Left
// {
// xHolder = X[i];
// for (int j = jj; ((j < numCells[i]) && (j < sidewaysLimit)) && totalDeltaArea > 0; j++)
// {
// ////extraDeltaArea = previousDA - decayRate;
// extraDeltaArea = previousDA - (decayRate/2);
// if (xHolder - s < 0)
// {
// xHolder = pbEnd - 1;
// s = 0;
// }
// else if (AboveWater[xHolder - s, Y[i]] == 0 && VolumeChange[xHolder - s, Y[i]] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder - s, Y[i]] += totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder - s, Y[i]] += decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder - s, Y[i]] += extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// s++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// if (totalDeltaArea > 0)
// {
// // Turn direction to up
// int k = 1;
// for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// {
// //
// extraDeltaArea = previousDA - decayRate;
// if (Y[i] + k >= ymax)
// {
// lost += totalDeltaArea;
// totalDeltaArea = 0;
// }
// else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[X[i], Y[i] + k] += totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[X[i], Y[i] + k] += decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[X[i], Y[i] + k] += extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// }
// k++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// }
// }
// //
// // Delta Area < 0
// //
// else if (DeltaArea < 0)
// {
// averageChange = averageChange * -1;
// firstDeltaArea = Math.Abs(DeltaArea * firstpercent);
// if (numCells[i] <= 1)
// {
// numCells[i] = 2;
// }
// if (VolumeChange[X[i], Y[i]] > averageChange)
// {
// VolumeChange[X[i], Y[i]] -= firstDeltaArea;
// }
// numCells[i]--;
// int xHolder;
// int s = 0;
// double extraDeltaArea = Math.Abs(DeltaArea + firstDeltaArea); // How much material do we have?
// double totalDeltaArea = Math.Abs(DeltaArea + firstDeltaArea); // Keep tracks of little bits that are left.
// double A = Math.Abs(DeltaArea + firstDeltaArea); // End Amount
// double P = 1; // Start Amount
// double t;
// //if (numCells[i] < shortShoreface)
// //{
// // t = MaxDist - 1; // time
// //}
// //else
// //{
// t = numCells[i] - 1;
// //} // time
// double decayRate = 0.01; //Math.Abs(firstDeltaArea); // Math.Abs(firstDeltaArea * UPpercent); // r, decay rate
// double previousDA = Math.Abs(firstDeltaArea);
// if (direction[i] == 1) // Up
// {
// xHolder = X[i];
// for (int j = 1; j < numCells[i] && totalDeltaArea > 0; j++)
// {
// //
// extraDeltaArea = previousDA - decayRate;
// if (Y[i] + j >= ymax)
// {
// lost += totalDeltaArea;
// totalDeltaArea = 0;
// }
// else if (AboveWater[X[i], Y[i] + j] == 0 && VolumeChange[X[i], Y[i] + j] > averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[X[i], Y[i] + j] -= totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[X[i], Y[i] + j] -= decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[X[i], Y[i] + j] -= extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// s++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// // Turn direction right/left
// if (totalDeltaArea > 0)
// {
// if (WaveAngleIn > -90 && WaveAngleIn < 90) // Go right
// {
// int k = 1;
// for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// {
// ////extraDeltaArea = previousDA - decayRate;
// extraDeltaArea = previousDA - (decayRate/2);
// if (xHolder + k > pbEnd - 1)
// {
// xHolder = 0;
// k = 0;
// }
// else if (AboveWater[xHolder + k, Y[i] - 1] == 0 && VolumeChange[xHolder + k, Y[i] - 1] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder + k, Y[i] - 1] -= totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder + k, Y[i] - 1] -= decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder + k, Y[i] - 1] -= extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// }
// k++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// else // go left
// {
// int k = 1;
// for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// {
// ////extraDeltaArea = previousDA - decayRate;
// extraDeltaArea = previousDA - (decayRate/2);
// if (xHolder - k < 0)
// {
// xHolder = 0;
// k = pbEnd - 1;
// }
// else if (AboveWater[xHolder - k, Y[i] - 1] == 0 && VolumeChange[xHolder - k, Y[i] - 1] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder - k, Y[i] - 1] -= totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder - k, Y[i] - 1] -= decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder - k, Y[i] - 1] -= extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// }
// k++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// }
// }
// else if (direction[i] == 3) // Right
// {
// xHolder = X[i];
// for (int j = 1; ((j < numCells[i]) && (j < sidewaysLimit)) && totalDeltaArea > 0; j++)
// {
// ////extraDeltaArea = previousDA - decayRate;
// extraDeltaArea = previousDA - (decayRate/2);
// if (xHolder + s > pbEnd - 1)
// {
// xHolder = 0;
// s = 0;
// }
// else if (AboveWater[xHolder + s, Y[i]] == 0 && VolumeChange[xHolder + s, Y[i]] > averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder + s, Y[i]] -= totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder + s, Y[i]] -= decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder + s, Y[i]] -= extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// s++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// if (totalDeltaArea > 0)
// {
// // Turn direction to up
// int k = 1;
// for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// {
// extraDeltaArea = previousDA - decayRate;
// if (Y[i] + k >= ymax)
// {
// lost += totalDeltaArea;
// totalDeltaArea = 0;
// }
// else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] > averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[X[i], Y[i] + k] -= totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[X[i], Y[i] + k] -= decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[X[i], Y[i] + k] -= extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// }
// k++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// }
// else if (direction[i] == 5) // Bottom
// {
// xHolder = X[i];
// for (int j = 1; j < numCells[i] && totalDeltaArea > 0; j++)
// {
// extraDeltaArea = previousDA - decayRate;
// if (Y[i] - j >= ymax)
// {
// lost += totalDeltaArea;
// totalDeltaArea = 0;
// }
// else if (AboveWater[X[i], Y[i] - j] == 0 && VolumeChange[X[i], Y[i] - j] > averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[X[i], Y[i] - j] -= totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[X[i], Y[i] - j] -= decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[X[i], Y[i] - j] -= extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// s++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// // Turn direction right/left
// if (totalDeltaArea > 0)
// {
// if (WaveAngleIn > -90 && WaveAngleIn < 90) // Go right
// {
// int k = 1;
// for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// {
// ////extraDeltaArea = previousDA - decayRate;
// extraDeltaArea = previousDA - (decayRate/2);
// if (xHolder + k > pbEnd - 1)
// {
// xHolder = 0;
// k = 0;
// }
// else if (AboveWater[xHolder + k, Y[i] - 1] == 0 && VolumeChange[xHolder + k, Y[i] - 1] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder + k, Y[i] - 1] -= totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder + k, Y[i] - 1] -= decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder + k, Y[i] - 1] -= extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// }
// k++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// else // go left
// {
// int k = 1;
// for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// {
// ////extraDeltaArea = previousDA - decayRate;
// extraDeltaArea = previousDA - (decayRate/2);
// if (xHolder - k < 0)
// {
// xHolder = 0;
// k = pbEnd - 1;
// }
// else if (AboveWater[xHolder - k, Y[i] - 1] == 0 && VolumeChange[xHolder - k, Y[i] - 1] < averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder - k, Y[i] - 1] -= totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder - k, Y[i] - 1] -= decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder - k, Y[i] - 1] -= extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// }
// k++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// }
// }
// else if (direction[i] == 7) // Left
// {
// xHolder = X[i];
// for (int j = 1; ((j < numCells[i]) && (j < sidewaysLimit)) && totalDeltaArea > 0; j++)
// {
// ////extraDeltaArea = previousDA - decayRate;
// extraDeltaArea = previousDA - (decayRate/2);
// if (xHolder - s < 0)
// {
// xHolder = pbEnd - 1;
// s = 0;
// }
// else if (AboveWater[xHolder - s, Y[i]] == 0 && VolumeChange[xHolder - s, Y[i]] > averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[xHolder - s, Y[i]] -= totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[xHolder - s, Y[i]] -= decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[xHolder - s, Y[i]] -= extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// s++;
// }
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// if (totalDeltaArea > 0)
// {
// // Turn direction to up
// int k = 1;
// for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// {
// //
// extraDeltaArea = previousDA - decayRate;
// if (Y[i] + k >= ymax)
// {
// lost += totalDeltaArea;
// totalDeltaArea = 0;
// }
// else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] > averageChange)
// {
// //if (totalDeltaArea < extraDeltaArea || extraDeltaArea < 0)
// if (totalDeltaArea < extraDeltaArea || totalDeltaArea < decayRate)
// {
// VolumeChange[X[i], Y[i] + k] -= totalDeltaArea;
// totalDeltaArea = 0;
// extraDeltaArea = 0;
// }
// else if ((extraDeltaArea <= 0 && totalDeltaArea > 0) || (extraDeltaArea < decayRate))
// {
// VolumeChange[X[i], Y[i] + k] -= decayRate;
// extraDeltaArea = 0;
// totalDeltaArea -= decayRate;
// previousDA = decayRate;
// }
// else
// {
// VolumeChange[X[i], Y[i] + k] -= extraDeltaArea;
// totalDeltaArea -= extraDeltaArea;
// previousDA = extraDeltaArea;
// }
// }
// k++;
// //totalDeltaArea -= extraDeltaArea;
// //previousDA = extraDeltaArea;
// }
// }
// }
// //if (direction[i] == 1) // Up
// //{
// // xHolder = X[i];
// // for (int j = 0; j < numCells[i] && totalDeltaArea > 0; j++)
// // {
// // extraDeltaArea = previousDA - decayRate;
// // if (Y[i] + j >= ymax)
// // {
// // lost += totalDeltaArea;
// // totalDeltaArea = 0;
// // }
// // else if (AboveWater[xHolder, Y[i] + j] == 0 && VolumeChange[xHolder, Y[i] + j] < averageChange)
// // {
// // if (totalDeltaArea < extraDeltaArea)
// // {
// // VolumeChange[xHolder, Y[i] + j] -= totalDeltaArea;
// // totalDeltaArea = 0;
// // extraDeltaArea = 0;
// // }
// // else
// // {
// // VolumeChange[xHolder, Y[i] + j] -= extraDeltaArea;
// // }
// // s++;
// // }
// // totalDeltaArea -= extraDeltaArea;
// // previousDA = extraDeltaArea;
// // }
// // // Turn direction right/left
// // if (totalDeltaArea > 0)
// // {
// // if (WaveAngleIn > -90 && WaveAngleIn < 90) // Go right
// // {
// // int k = 1;
// // for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// // {
// // extraDeltaArea = previousDA - decayRate;
// // if (xHolder + k > pbEnd - 1)
// // {
// // xHolder = 0;
// // k = 0;
// // }
// // else if (AboveWater[xHolder + k, Y[i] + 1] == 0 && VolumeChange[xHolder + k, Y[i] + 1] < averageChange)
// // {
// // if (totalDeltaArea < extraDeltaArea)
// // {
// // VolumeChange[xHolder + k, Y[i] + 1] -= totalDeltaArea;
// // totalDeltaArea = 0;
// // extraDeltaArea = 0;
// // }
// // else
// // {
// // VolumeChange[xHolder + k, Y[i] + 1] -= extraDeltaArea;
// // }
// // }
// // k++;
// // totalDeltaArea -= extraDeltaArea;
// // previousDA = extraDeltaArea;
// // }
// // }
// // else // go left
// // {
// // int k = 1;
// // for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// // {
// // extraDeltaArea = previousDA - decayRate;
// // if (xHolder - k < 0)
// // {
// // xHolder = 0;
// // k = pbEnd - 1;
// // }
// // else if (AboveWater[xHolder - k, Y[i] + 1] == 0 && VolumeChange[xHolder - k, Y[i] + 1] < averageChange)
// // {
// // if (totalDeltaArea < extraDeltaArea)
// // {
// // VolumeChange[xHolder - k, Y[i] + 1] -= totalDeltaArea;
// // totalDeltaArea = 0;
// // extraDeltaArea = 0;
// // }
// // else
// // {
// // VolumeChange[xHolder - k, Y[i] + 1] -= extraDeltaArea;
// // }
// // }
// // k++;
// // totalDeltaArea -= extraDeltaArea;
// // previousDA = extraDeltaArea;
// // }
// // }
// // }
// //}
// //else if (direction[i] == 3) // Right
// //{
// // xHolder = X[i];
// // for (int j = 0; j < numCells[i] && totalDeltaArea > 0; j++)
// // {
// // extraDeltaArea = previousDA - decayRate;
// // if (xHolder + s > pbEnd - 1)
// // {
// // xHolder = 0;
// // s = 0;
// // }
// // else if (AboveWater[xHolder + s, Y[i]] == 0 && VolumeChange[xHolder + s, Y[i]] < averageChange)
// // {
// // if (totalDeltaArea < extraDeltaArea)
// // {
// // VolumeChange[xHolder + s, Y[i]] -= totalDeltaArea;
// // totalDeltaArea = 0;
// // extraDeltaArea = 0;
// // }
// // else
// // {
// // VolumeChange[xHolder + s, Y[i]] -= extraDeltaArea;
// // }
// // s++;
// // }
// // totalDeltaArea -= extraDeltaArea;
// // previousDA = extraDeltaArea;
// // }
// // // Turn direction to up
// // // Share rest with north going cells, along all X-numcells
// // if (totalDeltaArea > 0)
// // {
// // int k = 1;
// // for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// // {
// // extraDeltaArea = previousDA - decayRate;
// // if (Y[i] + k >= ymax)
// // {
// // lost += totalDeltaArea;
// // totalDeltaArea = 0;
// // }
// // else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] < averageChange)
// // {
// // if (totalDeltaArea < extraDeltaArea)
// // {
// // VolumeChange[X[i], Y[i] + k] -= totalDeltaArea;
// // totalDeltaArea = 0;
// // extraDeltaArea = 0;
// // }
// // else
// // {
// // VolumeChange[X[i], Y[i] + k] -= extraDeltaArea;
// // }
// // }
// // k++;
// // totalDeltaArea -= extraDeltaArea;
// // previousDA = extraDeltaArea;
// // }
// // }
// //}
// ////else if (direction[i] == 5) // Bottom
// ////{
// //// for (int j = jj; j < numCells[i] && totalDeltaArea > 0; j++)
// //// {
// //// extraDeltaArea = previousDA - decayRate;
// //// if (Y[i] - j >= ymax)
// //// {
// //// lost += totalDeltaArea;
// //// totalDeltaArea = 0;
// //// }
// //// else if (AboveWater[X[i], Y[i] - j] == 0 && VolumeChange[X[i], Y[i] - j] < averageChange)
// //// {
// //// if (totalDeltaArea < extraDeltaArea)
// //// {
// //// VolumeChange[X[i], Y[i] - j] += totalDeltaArea;
// //// totalDeltaArea = 0;
// //// extraDeltaArea = 0;
// //// }
// //// else
// //// {
// //// VolumeChange[X[i], Y[i] - j] += extraDeltaArea;
// //// }
// //// }
// //// totalDeltaArea -= extraDeltaArea;
// //// previousDA = extraDeltaArea;
// //// }
// ////}
// //else if (direction[i] == 5) // Bottom
// //{
// // xHolder = X[i];
// // for (int j = 0; j < numCells[i] && totalDeltaArea > 0; j++)
// // {
// // extraDeltaArea = previousDA - decayRate;
// // if (Y[i] - j >= ymax)
// // {
// // lost += totalDeltaArea;
// // totalDeltaArea = 0;
// // }
// // else if (AboveWater[xHolder, Y[i] - j] == 0 && VolumeChange[xHolder, Y[i] - j] < averageChange)
// // {
// // if (totalDeltaArea < extraDeltaArea)
// // {
// // VolumeChange[xHolder, Y[i] - j] -= totalDeltaArea;
// // totalDeltaArea = 0;
// // extraDeltaArea = 0;
// // }
// // else
// // {
// // VolumeChange[xHolder, Y[i] - j] -= extraDeltaArea;
// // }
// // s++;
// // }
// // totalDeltaArea -= extraDeltaArea;
// // previousDA = extraDeltaArea;
// // }
// // // Turn direction right/left
// // if (totalDeltaArea > 0)
// // {
// // if (WaveAngleIn > -90 && WaveAngleIn < 90) // Go right
// // {
// // int k = 1;
// // for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// // {
// // extraDeltaArea = previousDA - decayRate;
// // if (xHolder + k > pbEnd - 1)
// // {
// // xHolder = 0;
// // k = 0;
// // }
// // else if (AboveWater[xHolder + k, Y[i] - 1] == 0 && VolumeChange[xHolder + k, Y[i] - 1] < averageChange)
// // {
// // if (totalDeltaArea < extraDeltaArea)
// // {
// // VolumeChange[xHolder + k, Y[i] - 1] -= totalDeltaArea;
// // totalDeltaArea = 0;
// // extraDeltaArea = 0;
// // }
// // else
// // {
// // VolumeChange[xHolder + k, Y[i] - 1] -= extraDeltaArea;
// // }
// // }
// // k++;
// // totalDeltaArea -= extraDeltaArea;
// // previousDA = extraDeltaArea;
// // }
// // }
// // else // go left
// // {
// // int k = 1;
// // for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// // {
// // extraDeltaArea = previousDA - decayRate;
// // if (xHolder - k < 0)
// // {
// // xHolder = 0;
// // k = pbEnd - 1;
// // }
// // else if (AboveWater[xHolder - k, Y[i] - 1] == 0 && VolumeChange[xHolder - k, Y[i] - 1] < averageChange)
// // {
// // if (totalDeltaArea < extraDeltaArea)
// // {
// // VolumeChange[xHolder - k, Y[i] - 1] -= totalDeltaArea;
// // totalDeltaArea = 0;
// // extraDeltaArea = 0;
// // }
// // else
// // {
// // VolumeChange[xHolder - k, Y[i] - 1] -= extraDeltaArea;
// // }
// // }
// // k++;
// // totalDeltaArea -= extraDeltaArea;
// // previousDA = extraDeltaArea;
// // }
// // }
// // }
// //}
// //else if (direction[i] == 7) // Left
// //{
// // xHolder = X[i];
// // for (int j = 0; j < numCells[i] && totalDeltaArea > 0; j++)
// // {
// // extraDeltaArea = previousDA - decayRate;
// // if (xHolder - s < 0)
// // {
// // xHolder = pbEnd - 1;
// // s = 0;
// // }
// // else if (AboveWater[xHolder - s, Y[i]] == 0 && VolumeChange[xHolder - s, Y[i]] < averageChange)
// // {
// // if (totalDeltaArea < extraDeltaArea)
// // {
// // VolumeChange[xHolder - s, Y[i]] -= totalDeltaArea;
// // totalDeltaArea = 0;
// // extraDeltaArea = 0;
// // }
// // else
// // {
// // VolumeChange[xHolder - s, Y[i]] -= extraDeltaArea;
// // }
// // s++;
// // }
// // totalDeltaArea -= extraDeltaArea;
// // previousDA = extraDeltaArea;
// // }
// // if (totalDeltaArea > 0)
// // {
// // // Turn direction to up
// // int k = 1;
// // for (int j = numCells[i]; j < MaxDist && totalDeltaArea > 0; j++)
// // {
// // extraDeltaArea = previousDA - decayRate;
// // if (Y[i] + k >= ymax)
// // {
// // lost += totalDeltaArea;
// // totalDeltaArea = 0;
// // }
// // else if (AboveWater[X[i], Y[i] + k] == 0 && VolumeChange[X[i], Y[i] + k] < averageChange)
// // {
// // if (totalDeltaArea < extraDeltaArea)
// // {
// // VolumeChange[X[i], Y[i] + k] -= totalDeltaArea;
// // totalDeltaArea = 0;
// // extraDeltaArea = 0;
// // }
// // else
// // {
// // VolumeChange[X[i], Y[i] + k] -= extraDeltaArea;
// // }
// // }
// // k++;
// // totalDeltaArea -= extraDeltaArea;
// // previousDA = extraDeltaArea;
// // }
// // }
// //}
// }
//}
//// DEBUGGING START
//if (counter == 365 && ((i == 88) || (i == 89) || (i == 90) || (i == 91) || (i == 92) || (i == 93) || (i == 94) || (i == 95) || (i == 96) || (i == 97) || (i == 98) || (i == 99) || (i == 100)))
//{
// StreamWriter DEBUG_FILE_VolChange = File.AppendText("OUTPUT_FILES/DEBUG_FILE_VolChange_" + i + ".out");
// for (int s = ymax - 1; s >= 0; s--)
// {
// for (int r = 0; r < pbEnd; r++)
// {
// DEBUG_FILE_VolChange.Write(VolumeChange[r, s] + " ");
// }
// DEBUG_FILE_VolChange.Write(Environment.NewLine);
// }
// DEBUG_FILE_VolChange.Close();
//}
//// DEBUGGING END
}
void ErodeTheBeach(int i)
{
// This function decreases the amount of sand in each cell of the TotalBeachCell array
// by a uniform amount (ErosionRatePerYear)
// Changes PercentFullSand[][]
// LMV
//double PercentEroded = 0.0;
//if (InShadow[i] == 'n')
//{
// //PercentEroded = ((ErosionRatePerYear * TimeStepValue) / 365) / CellWidth;
// PercentEroded = ((ErosionRatePerYear * CellWidth * TElevationCS[X[i], Y[i]] * TimeStepValue) / 365);
//}
//else if (InShadow[i] == 'y')
//{
// PercentEroded = 0.0;
//}
//// Not enough sand...
////if (PercentEroded > PercentFullSand[X[i], Y[i]])
//if (PercentEroded > Volume[X[i], Y[i]])
//{
// // ...and no rock
// if (PercentFullRock[X[i], Y[i]] == 0.0)
// {
// // ...but there is sand behind that can be stolen
// //if (PercentEroded < (PercentFullSand[X[i], Y[i]] + PercentFullSand[XBehind[i], YBehind[i]]))
// if (PercentEroded < (Volume[X[i], Y[i]] + Volume[XBehind[i], YBehind[i]]))
// {
// //PercentFullSand[XBehind[i], YBehind[i]] -= PercentEroded - PercentFullSand[X[i], Y[i]];
// //PercentFullSand[X[i], Y[i]] = 0.0;
// Volume[XBehind[i], YBehind[i]] -= PercentEroded - Volume[X[i], Y[i]];
// Volume[X[i], Y[i]] = 0.0;
// }
// //else if (PercentEroded > (PercentFullSand[X[i], Y[i]] + PercentFullSand[XBehind[i], YBehind[i]]))
// else if (PercentEroded > (Volume[X[i], Y[i]] + Volume[XBehind[i], YBehind[i]]))
// {
// Volume[XBehind[i], YBehind[i]] = 0.0;
// Volume[X[i], Y[i]] = 0.0;
// }
// }
// else
// {
// Volume[X[i], Y[i]] = 0.0;
// }
//}
////normal case, enough sand
//else
//{
// Volume[X[i], Y[i]] -= PercentEroded;
//}
}
void FixBeach()
{
////// Hopefully addresses strange problems caused by filling/emptying of cells
////// Looks at entire data set
////// Find unattached pieces of sand and moves them back to the shore
////// Takes care of 'floating bits' of sand
////// Also takes care of over/under filled beach pieces
////// Revised 5/21/02 to move sand to all adjacent neighbors sandrevt.c
////// Changes global variable PercentFullSand[][]
////// Uses and can change AllBeach[][]
////// sandrevx.c - added sweepsign to reduce chances of asymmetrical artifacts
////// LMV rock fix - do not fix bare bedrock cells
//int i, x, y, sweepsign, done, counter;
//int fillcells3 = 0;
//int Corner = 0;
//int ystart;
//if (RandZeroToOne() * 2 > 1)
//{
// sweepsign = 1;
//}
//else
//{
// sweepsign = 0;
//}
//for (y = 1; y < ShadowYMax - 1; y++)
//{
// for (i = 1; i < pbEnd - 1; i++)
// {
// if (sweepsign == 1)
// {
// x = i;
// }
// else
// {
// x = (pbEnd - 1) - i;
// }
// Corner = 0;
// // Take care of 'loose' bits of sand
// if (Corner == 0)
// {
// fillcells3 = 0;
// // Beach in cell, but bottom, top, right, and left neighbors have some in
// if ((Elevation[x, y] != 0.0) &&
// (Elevation[x, y + 1] > 0) &&
// (Elevation[x + 1, y] > 0) &&
// (Elevation[x, y - 1] > 0) &&
// (Elevation[x - 1, y] > 0) &&
// (AboveWater[x, y] == 0))
// {
// // distribute to partially full neighbors
// if ((PercentFullSand[x, y - 1] < MaxFillCell) &&
// ((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) > 0.0))
// //if (((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) < WaterHeight) &&
// //((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) > 0.0))
// {
// fillcells3 += 1;
// }
// if (((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) < MaxFillCell) &&
// ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) > 0.0))
// //if (((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) < WaterHeight) &&
// // ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) > 0.0))
// {
// fillcells3 += 1;
// }
// if (((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) < MaxFillCell) &&
// ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) > 0.0))
// //if (((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) < WaterHeight) &&
// // ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) > 0.0))
// {
// fillcells3 += 1;
// }
// if (((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) < MaxFillCell) &&
// ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) > 0.0))
// //if (((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) < WaterHeight) &&
// // ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) > 0.0))
// {
// fillcells3 += 1;
// }
// if ((fillcells3 > 0) && (fillcells3 <= 4))
// {
// if (((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) < MaxFillCell) &&
// ((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) > 0.0))
// //if (((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) < WaterHeight) &&
// // ((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) > 0.0))
// {
// PercentFullSand[x, y - 1] += PercentFullSand[x, y] / fillcells3;
// }
// if (((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) < MaxFillCell) &&
// ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) > 0.0))
// //if (((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) < WaterHeight) &&
// // ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) > 0.0))
// {
// PercentFullSand[x, y + 1] += PercentFullSand[x, y] / fillcells3;
// }
// if (((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) < MaxFillCell) &&
// ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) > 0.0))
// //if (((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) < WaterHeight) &&
// // ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) > 0.0))
// {
// PercentFullSand[x + 1, y] += PercentFullSand[x, y] / fillcells3;
// }
// if (((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) < MaxFillCell) &&
// ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) > 0.0))
// //if (((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) < WaterHeight) &&
// // ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) > 0.0))
// {
// PercentFullSand[x - 1, y] += PercentFullSand[x, y] / fillcells3;
// }
// }
// else
// {
// ystart = ymax - 1;
// while (AllBeach[x, ystart] == 0)
// {
// ystart -= 1;
// }
// ystart += 1;
// PercentFullSand[x, ystart] += PercentFullSand[x, y];
// PercentFullSand[x, y] = 0.0;
// AllBeach[x, y] = 0;
// ystart = ymax - 1;
// while (AllRock[x, ystart] == 'n')
// {
// ystart -= 1;
// }
// ystart += 1;
// PercentFullRock[x, ystart] += PercentFullRock[x, y];
// PercentFullRock[x, y] = 0.0;
// AllRock[x, y] = 'n';
// if (PercentFullRock[x, ystart] >= MaxFillCell)
// //if (PercentFullRock[x, ystart] > WaterHeight)
// {
// AllRock[x, ystart] = 'y';
// PercentFullRock[x, ystart + 1] += (PercentFullRock[x, ystart] - 1);
// PercentFullRock[x, ystart] = MaxFillCell;
// }
// }
// PercentFullSand[x, y] = 0.0;
// AllBeach[x, y] = 0;
// // If we have overfilled any of the cells in this loop, need to OopsImFull()
// if ((PercentFullSand[x, y - 1] + PercentFullRock[x, y - 1]) > MaxFillCell)
// {
// OopsImFull(x, y - 1);
// }
// if ((PercentFullSand[x - 1, y] + PercentFullRock[x - 1, y]) > MaxFillCell)
// {
// OopsImFull(x - 1, y);
// }
// if ((PercentFullSand[x + 1, y] + PercentFullRock[x + 1, y]) > MaxFillCell)
// {
// OopsImFull(x + 1, y);
// }
// if ((PercentFullSand[x, y + 1] + PercentFullRock[x, y + 1]) > MaxFillCell)
// {
// OopsImFull(x, y + 1);
// }
// }
// }
// }
// }
// // now make sure there aren't any overfull or underfull cells
// done = FALSE;
// for (counter = 0; counter < 10 && done == 0; counter++)
// {
// done = TRUE;
// for (y = 1; y < ymax - 1; y++)
// {
// for (x = 1; x < pbEnd - 1; x++)
// {
// if ((PercentFullSand[x, y] + PercentFullRock[x, y] > MaxFillCell)
// || (PercentFullSand[x, y] + PercentFullRock[x, y] < 0.0)
// || PercentFullSand[x, y] < 0.0)
// {
// done = FALSE;
// }
// if (PercentFullSand[x, y] + PercentFullRock[x, y] > MaxFillCell)
// {
// OopsImFull(x, y);
// }
// if (PercentFullSand[x, y] + PercentFullRock[x, y] < -0.000001)
// {
// OopsImEmpty(x, y);
// }
// if (PercentFullSand[x, y] < -0.000001)
// {
// OopsImEmpty(x, y);
// }
// }
// }
// }
//}
}
//CM - New Slope
void FindAverageShoreface()
{
// Use the ShorelineAngle[] to find which angle the shoreline is facing
// Calculate the local shoreface slope
// Calculate which cells will gain/loose material (where the shoreface slope is drawn)
int i;
int MinDist = 1;
//int MaxDist = 20;
int[] xSFCell = new int[MaxBeachLength]; // x position of the end of the shoreface slope
int[] ySFCell = new int[MaxBeachLength]; // y position of the end of the shoreface slope
int[] count = new int[MaxBeachLength];
int j;
int k;
double TotalX;
double TotalY;
double XY;
double Xsq;
double Ysq;
Array.Clear(direction, 0, direction.Length);
Array.Clear(numCells, 0, numCells.Length);
// Direction we are looking in
for (i = 0; i <= TotalBeachCells - 1; i++)
{
//if ((ShorelineAngle[i] < 0.3926991) && (ShorelineAngle[i] >= -0.3926991))
//{
// direction[i] = 1; // Top
//}
//else if ((ShorelineAngle[i] < -0.3926991) && (ShorelineAngle[i] >= -1.178097))
//{
// direction[i] = 2; // Top Right
//}
//else if ((ShorelineAngle[i] < -1.178097) && (ShorelineAngle[i] >= -1.9634954))
//{
// direction[i] = 3; // Right
//}
//else if ((ShorelineAngle[i] < -1.9634954) && (ShorelineAngle[i] >= -2.7488936))
//{
// direction[i] = 4; // Bottom Right
//}
//else if (((ShorelineAngle[i] < -2.7488936) && (ShorelineAngle[i] >= -3.15905)) || ((ShorelineAngle[i] <= 3.15905) && (ShorelineAngle[i] >= 2.7488936)))
//{
// direction[i] = 5; // Bottom
//}
//else if ((ShorelineAngle[i] < 2.7488936) && (ShorelineAngle[i] >= 1.9634954))
//{
// direction[i] = 6; // Bottom Left
//}
//else if ((ShorelineAngle[i] < 1.9634954) && (ShorelineAngle[i] >= 1.178097))
//{
// direction[i] = 7; // Left
//}
//else if ((ShorelineAngle[i] < 1.178097) && (ShorelineAngle[i] >= 0.3926991))
//{
// direction[i] = 8; // Top Left
//}
//if (ShorelineAngle[i] < 0)
//{
// Angle_1[i] = Angle_1[i] * -1;
//}
if ((ShorelineAngle[i] /*+ Angle_1[i]*/ <= 0.785398) && (ShorelineAngle[i] /*+ Angle_1[i]*/ > -0.785398)) // 0.785...radians = 45o
{
direction[i] = 1; // Up
}
else if ((ShorelineAngle[i] /*+ Angle_1[i]*/ <= -0.785398) && (ShorelineAngle[i] /*+ Angle_1[i]*/ > -2.35619449060255))
{
direction[i] = 3; // Right
}
else if (((ShorelineAngle[i] /*+ Angle_1[i]*/ <= 3.141592654) && (ShorelineAngle[i] /*+ Angle_1[i]*/ > 2.35619449060255)) || ((ShorelineAngle[i] /*+ Angle_1[i]*/ <= -2.35619449060255) && (ShorelineAngle[i] /*+ Angle_1[i]*/ >= -3.141592654))) // 3.141...radians = 180o
{
// CM 07.12.17 - if it's the cell on the end of the spit, it's direction should go right (longshore drift)
if (X[i] > X[i + 1] && X[i] > X[i - 1])
{
direction[i] = 3;
}
else
{
direction[i] = 5; // Down
}
}
else if ((ShorelineAngle[i] /*+ Angle_1[i]*/ <= 2.35619449060255) && ShorelineAngle[i] /*+ Angle_1[i]*/ > 0.785398) // 2.35... radians = 135o
{
direction[i] = 7; // Left
}
else
{
direction[i] = 1; // Up
}
//else if (ShorelineAngle[i] + Angle_1[i] == 0.785398163397448)
//{
// Random rand = new Random();
// int RandNo = rand.Next(0, 2);
// if (RandNo == 0)
// {
// RandNo = 5;
// }
// else if (RandNo == 1)
// {
// RandNo = 7;
// }
// direction[i] = RandNo;
//}
//else if (ShorelineAngle[i] + Angle_1[i] == -0.785398163397448)
//{
// Random rand = new Random();
// int RandNo = rand.Next(0, 2);
// if (RandNo == 0)
// {
// RandNo = 1;
// }
// else if (RandNo == 1)
// {
// RandNo = 7;
// }
// direction[i] = RandNo;
//}
//else if (ShorelineAngle[i] + Angle_1[i] == 2.35619449060255)
//{
// Random rand = new Random();
// int RandNo = rand.Next(0, 2);
// if (RandNo == 0)
// {
// RandNo = 3;
// }
// else if (RandNo == 1)
// {
// RandNo = 5;
// }
// direction[i] = RandNo;
//}
//else if (ShorelineAngle[i] + Angle_1[i] == -2.35619449060255)
//{
// Random rand = new Random();
// int RandNo = rand.Next(0, 2);
// if (RandNo == 0)
// {
// RandNo = 1;
// }
// else if (RandNo == 1)
// {
// RandNo = 3;
// }
// direction[i] = RandNo;
//}
//if ((ShorelineAngle[i] < 0.3926991) && (ShorelineAngle[i] >= -0.3926991)) // +-22.5
//{
// direction[i] = 1; // Up
//}
//else if ((ShorelineAngle[i] < -0.3926991) && (ShorelineAngle[i] >= -1.178097)) // -22.5^o - -67.5^o
//{
// direction[i] = 1; // Top Right
//}
//else if ((ShorelineAngle[i] < -1.178097) && (ShorelineAngle[i] >= -1.9634954)) // -67.5^o - -112.5^o
//{
// direction[i] = 3; // Right
//}
//else if ((ShorelineAngle[i] < -1.9634954) && (ShorelineAngle[i] >= -2.7488936)) // -112.5^o - -157.5^o
//{
// direction[i] = 3; // Bottom Right
//}
//else if (((ShorelineAngle[i] < -2.7488936) && (ShorelineAngle[i] >= -3.14159)) || ((ShorelineAngle[i] <= 3.14159) && (ShorelineAngle[i] >= 2.7488936))) // (=-)157.5^o - 180^o
//{
// direction[i] = 5; // Bottom
//}
//else if ((ShorelineAngle[i] < 2.7488936) && (ShorelineAngle[i] >= 1.9634954)) // 157.5^o - 112.5^o
//{
// direction[i] = 7; // Bottom Left
//}
//else if ((ShorelineAngle[i] < 1.9634954) && (ShorelineAngle[i] >= 1.178097)) // 112.5^o - 67.5^o
//{
// direction[i] = 7; // Left
//}
//else if ((ShorelineAngle[i] < 1.178097) && (ShorelineAngle[i] >= 0.3926991)) // 67.5^o - 22.5^o
//{
// direction[i] = 1; // Top Left
//}
//if ((ShorelineAngle[i] > -0.785398) && (ShorelineAngle[i] < 0.785398) || (ShorelineAngle[i] == -0.785398) || (ShorelineAngle[i] == -2.35619)) // 0.785...radians = 45o
//{
// direction[i] = 1; // Up
//}
//else if ((ShorelineAngle[i] < -0.785398) && (ShorelineAngle[i] > -2.35619) || (ShorelineAngle[i] == 2.35619))
//{
// direction[i] = 3; // Right
//}
//else if (((ShorelineAngle[i] < -2.35619) && (ShorelineAngle[i] > -3.14159)) || ((ShorelineAngle[i] < 3.14159) && (ShorelineAngle[i] > 2.35619))) // 3.141...radians = 180o
//{
// direction[i] = 5; // Down
//}
//else if ((ShorelineAngle[i] < 2.35619) && (ShorelineAngle[i] > 0.785398) || (ShorelineAngle[i] == 0.785398)) // 2.35... radians = 135o
//{
// direction[i] = 7; // Left
//}
//else if ((ShorelineAngle[i] == 0.785398) || (ShorelineAngle[i] == -0.785398) || (ShorelineAngle[i] == 2.35619) || (ShorelineAngle[i] == -2.35619))
//{
// Random rand = new Random();
// int RandNo = rand.Next(1, 5);
// ShorelineAngle[i] = RandNo;
//}
//count[i] = 0;
//TotalX = 0;
//TotalY = 0;
//XY = 0;
//Xsq = 0;
//Ysq = 0;
//XY += ((count[i] + 1) * CellWidth) * (TElevationDomain[X[i], Y[i]]);
//Xsq += Math.Pow(((count[i] + 1) * CellWidth), 2);
//Ysq += Math.Pow((TElevationDomain[X[i], Y[i]]), 2);
//TotalY += TElevationDomain[X[i], Y[i]];
//TotalX += (count[i] + 1) * CellWidth;
//count[i]++;
// // Average Shoreface Slope
// if (direction[i] == 1)
// {
// k = Y[i] + 1;
// while (k < ymax && AboveWater[X[i], k] == 0)
// {
// XY += ((count[i] + 1) * CellWidth) * (TElevationDomain[X[i], k]);
// Xsq += Math.Pow(((count[i] + 1) * CellWidth), 2);
// Ysq += Math.Pow((TElevationDomain[X[i], k]), 2);
// TotalY += TElevationDomain[X[i], k];
// TotalX += (count[i] + 1) * CellWidth;
// k++;
// count[i]++;
// }
// }
// else if (direction[i] == 2)
// {
// j = X[i] + 1;
// k = Y[i] + 1;
// while (j < pbEnd && j >= 0 && k >= 0 && k < ymax && AboveWater[j, k] == 0)
// {
// XY += ((count[i] + 1) * CellWidth) * (TElevationDomain[j, k]);
// Xsq += Math.Pow(((count[i] + 1) * CellWidth), 2);
// Ysq += Math.Pow((TElevationDomain[j, k]), 2);
// TotalY += TElevationDomain[j, k];
// TotalX += (count[i] + 1) * CellWidth;
// j++;
// k++;
// count[i]++;
// }
// }
// else if (direction[i] == 3)
// {
// j = X[i] + 1;
// while (j < pbEnd && AboveWater[j, Y[i]] == 0)
// {
// XY += ((count[i] + 1) * CellWidth) * (TElevationDomain[j, Y[i]]);
// Xsq += Math.Pow(((count[i] + 1) * CellWidth), 2);
// Ysq += Math.Pow((TElevationDomain[j, Y[i]]), 2);
// TotalY += TElevationDomain[j, Y[i]];
// TotalX += (count[i] + 1) * CellWidth;
// j++;
// count[i]++;
// if (j == pbEnd - 1)
// {
// j = 0;
// }
// }
// }
// else if (direction[i] == 4)
// {
// j = X[i] + 1;
// k = Y[i] - 1;
// while (j < pbEnd && j >= 0 && k >= 0 && k < ymax && AboveWater[j, k] == 0)
// {
// XY += ((count[i] + 1) * CellWidth) * (TElevationDomain[j, k]);
// Xsq += Math.Pow(((count[i] + 1) * CellWidth), 2);
// Ysq += Math.Pow((TElevationDomain[j, k]), 2);
// TotalY += TElevationDomain[j, k];
// TotalX += (count[i] + 1) * CellWidth;
// j++;
// k--;
// count[i]++;
// }
// }
// else if (direction[i] == 5)
// {
// j = Y[i] - 1;
// while (j >= 0 && AboveWater[X[i], j] == 0)
// {
// XY += ((count[i] + 1) * CellWidth) * (TElevationDomain[X[i], j]);
// Xsq += Math.Pow(((count[i] + 1) * CellWidth), 2);
// Ysq += Math.Pow((TElevationDomain[X[i], j]), 2);
// TotalY += TElevationDomain[X[i], j];
// TotalX += (count[i] + 1) * CellWidth;
// j--;
// count[i]++;
// }
// }
// else if (direction[i] == 6)
// {
// j = X[i] - 1;
// k = Y[i] - 1;
// while (j < pbEnd && j >= 0 && k >= 0 && k < ymax && AboveWater[j, k] == 0)
// {
// XY += ((count[i] + 1) * CellWidth) * (TElevationDomain[j, k]);
// Xsq += Math.Pow(((count[i] + 1) * CellWidth), 2);
// Ysq += Math.Pow((TElevationDomain[j, k]), 2);
// TotalY += TElevationDomain[j, k];
// TotalX += (count[i] + 1) * CellWidth;
// j--;
// k--;
// count[i]++;
// }
// }
// else if (direction[i] == 7)
// {
// j = X[i] - 1;
// while (j >= 0 && AboveWater[j, Y[i]] == 0)
// {
// XY += ((count[i] + 1) * CellWidth) * (TElevationDomain[j, Y[i]]);
// Xsq += Math.Pow(((count[i] + 1) * CellWidth), 2);
// Ysq += Math.Pow((TElevationDomain[j, Y[i]]), 2);
// TotalY += TElevationDomain[j, Y[i]];
// TotalX += (count[i] + 1) * CellWidth;
// j--;
// count[i]++;
// if (j == 0)
// {
// j = pbEnd - 1;
// }
// }
// }
// else if (direction[i] == 8)
// {
// j = X[i] - 1;
// k = Y[i] + 1;
// while (j < pbEnd && j >= 0 && k >= 0 && k < ymax && AboveWater[j, k] == 0)
// {
// XY += ((count[i] + 1) * CellWidth) * (TElevationDomain[j, k]);
// Xsq += Math.Pow(((count[i] + 1) * CellWidth), 2);
// Ysq += Math.Pow((TElevationDomain[j, k]), 2);
// TotalY += TElevationDomain[j, k];
// TotalX += (count[i] + 1) * CellWidth;
// j--;
// k++;
// count[i]++;
// }
// }
// localSFS[i] = Math.Abs((count[i] * (XY) - (TotalX) * (TotalY)) / (count[i] * (Xsq) - (Math.Pow(TotalX, 2))));
// count[i] = 0;
// if (direction[i] == 1) // Top
// {
// int n = 1;
// int s = 1;
// while ((Y[i] + s < ymax - 1) && (AboveWater[X[i], Y[i] + s] == 0))
// {
// n++;
// s++;
// }
// count[i] = n;
// }
// if (direction[i] == 2) // Top Right
// {
// int n = 1;
// int s = 1;
// while ((X[i] + s < pbEnd - 1) && (Y[i] + s < ymax - 1) && (AboveWater[X[i] + s, Y[i] + s] == 0))
// {
// n++;
// s++;
// }
// count[i] = n;
// }
// if (direction[i] == 3) // Right
// {
// int n = 1;
// int s = 1;
// while ((X[i] + s < pbEnd - 1) && (AboveWater[X[i] + s, Y[i]] == 0))
// {
// n++;
// s++;
// }
// count[i] = n;
// }
// if (direction[i] == 4) // Bottom Right
// {
// int n = 1;
// int s = 1;
// while ((X[i] + s < pbEnd - 1) && (Y[i] - s > 1) && (AboveWater[X[i] + s, Y[i] - s] == 0))
// {
// n++;
// s++;
// }
// count[i] = n;
// }
// if (direction[i] == 5) // Bottom
// {
// int n = 1;
// int s = 1;
// while ((Y[i] - s > 1) && (AboveWater[X[i], Y[i] - s] == 0))
// {
// n++;
// s++;
// }
// count[i] = n;
// }
// if (direction[i] == 6) // Bottom Left
// {
// int n = 1;
// int s = 1;
// while ((X[i] - s > 1) && (Y[i] - s > 1) && (AboveWater[X[i] - s, Y[i] - s] == 0))
// {
// n++;
// s++;
// }
// count[i] = n;
// }
// if (direction[i] == 7) // Left
// {
// int n = 1;
// int s = 1;
// while ((X[i] - s > 1) && (AboveWater[X[i] - s, Y[i]] == 0))
// {
// n++;
// s++;
// }
// count[i] = n;
// }
// if (direction[i] == 8) // Top Left
// {
// int n = 1;
// int s = 1;
// while ((X[i] - s > 1) && (Y[i] + s < ymax - 1) && (AboveWater[X[i] - s, Y[i] + s] == 0))
// {
// n++;
// s++;
// }
// count[i] = n;
// }
int numstep = 1;
double extraAmount = 0.1;
//newdirection:
// How many cells out does the slope extend (only to a dip in the coastline)
if (direction[i] == 1) // Top
{
int n = 1;
int s = 1;
while ((Y[i] + s < ymax - 1) && (TElevationDomain[X[i], Y[i] + s] <= TElevationDomain[X[i], Y[i] + (s - numstep)] + extraAmount) && (numCells[i] < MaxDist) && AboveWater[X[i], Y[i] + s] == 0)
{
n++;
s++;
}
numCells[i] = n;
}
else if (direction[i] == 2) // Top Right
{
int n = 1;
int s = 1;
while ((X[i] + s < pbEnd - 1) && (Y[i] + s < ymax - 1) && (TElevationDomain[X[i] + s, Y[i] + s] <= TElevationDomain[X[i] + (s - numstep), Y[i] + (s - numstep)] + extraAmount) && AboveWater[X[i] + s, Y[i] + s] == 0)
{
n++;
s++;
}
numCells[i] = n;
}
else if (direction[i] == 3) // Right
{
//if (AboveWater[X[i] + 1, Y[i]] == 1)
//{
// direction[i] = 1;
// goto newdirection;
//}
int n = 1;
int s = 1;
int xHolder = X[i];
int breakflag = 0;
//if (AboveWater[X[i] + 1, Y[i]] == 1)
//{
// Y[i] = Y[i] + 1;
//}
while (n < MaxDist && breakflag == 0)
{
if (xHolder + s > pbEnd - 1)
{
xHolder = 0;
int pbIt = -2;
for (s = 0; (s < 2) && (n < MaxDist); s++)
{
if ((TElevationDomain[xHolder + s, Y[i]] <= TElevationDomain[pbEnd + pbIt, Y[i]] + extraAmount) && AboveWater[xHolder + s, Y[i]] == 0)
{
n++;
pbIt++;
}
else
{
breakflag = 1;
break;
}
}
}
else if ((TElevationDomain[xHolder + s, Y[i]] <= TElevationDomain[xHolder + (s - numstep), Y[i]] + extraAmount) && AboveWater[xHolder + s, Y[i]] == 0)
{
n++;
s++;
}
else
{
break;
}
}
numCells[i] = n;
//if (numCells[i] < 5)
//{
// direction[i] = 1;
// goto newdirection;
//}
breakflag = 0;
}
else if (direction[i] == 4) // Bottom Right
{
int n = 1;
int s = 1;
while ((X[i] + s < pbEnd - 1) && (Y[i] - s > 1) && (TElevationDomain[X[i] + s, Y[i] - s] <= TElevationDomain[X[i] + (s - numstep), Y[i] - (s - numstep)] + extraAmount) && AboveWater[X[i] + s, Y[i] - s] == 0)
{
n++;
s++;
}
numCells[i] = n;
}
else if (direction[i] == 5) // Bottom
{
int n = 1;
int s = 1;
while ((Y[i] - s > 1) && (TElevationDomain[X[i], Y[i] - s] <= TElevationDomain[X[i], Y[i] - (s - numstep)] + extraAmount) && AboveWater[X[i], Y[i] - s] == 0)
{
n++;
s++;
}
numCells[i] = n;
//if (numCells[i] < 5)
//{
// direction[i] = 3;
// goto newdirection;
//}
}
else if (direction[i] == 6) // Bottom Left
{
int n = 1;
int s = 1;
while ((X[i] - s > 1) && (Y[i] - s > 1) && (TElevationDomain[X[i] - s, Y[i] - s] <= TElevationDomain[X[i] - (s - numstep), Y[i] - (s - numstep)] + extraAmount) && AboveWater[X[i] - s, Y[i] - s] == 0)
{
n++;
s++;
}
numCells[i] = n;
}
else if (direction[i] == 7) // Left
{
//if (AboveWater[X[i] - 1, Y[i]] == 1)
//{
// direction[i] = 1;
// goto newdirection;
//}
int n = 1;
int s = 1;
int xHolder = X[i];
int breakflag = 0;
//if (AboveWater[X[i] - 1, Y[i]] == 1)
//{
// Y[i] = Y[i] + 1;
//}
while (n < MaxDist && breakflag == 0)
{
if (xHolder - s < 0)
{
xHolder = pbEnd - 1;
int pbIt = 1;
for (s = 0; (s < 2) && (n < MaxDist); s++)
{
if ((TElevationDomain[xHolder - s, Y[i]] <= TElevationDomain[0 + pbIt, Y[i]] + extraAmount) && AboveWater[xHolder - s, Y[i]] == 0)
{
n++;
pbIt--;
}
else
{
breakflag = 1;
break;
}
}
}
else if ((TElevationDomain[xHolder - s, Y[i]] <= TElevationDomain[(xHolder - s) + numstep, Y[i]] + extraAmount) && AboveWater[xHolder - s, Y[i]] == 0)
{
n++;
s++;
}
else
{
break;
}
}
numCells[i] = n;
//if (numCells[i] < 5)
//{
// direction[i] = 1;
// goto newdirection;
//}
breakflag = 0;
}
else if (direction[i] == 8) // Top Left
{
int n = 1;
int s = 1;
while ((X[i] - s > 1) && (Y[i] + s < ymax - 1) && (TElevationDomain[X[i] - s, Y[i] + s] <= TElevationDomain[X[i] - (s - numstep), Y[i] + (s - numstep)] + extraAmount) && AboveWater[X[i] - s, Y[i] + s] == 0)
{
n++;
s++;
}
numCells[i] = n;
}
if (numCells[i] > MaxDist)
{
numCells[i] = MaxDist;
}
}
}
void RedrawCoastline()
{
//int i;
//int repeat = 1;
//int repeat2 = 1;
//double celldifference = 0;
//int a = 1;
//for (i = 0; i <= TotalBeachCells; i++)
//{
// //repeat = 1;
// //// Acreting
// //while (repeat == 1)
// //{
// if (TElevationDomain[X[i], Y[i]] >= maxDomainDepth + WaterLevel + WetDryThreshold)
// {
// AboveWater[X[i], Y[i]] = 1;
// //while (repeat2 == 1)
// //{
// celldifference = (CellWidth * a) * Math.Tan((ShorefaceSlope * CellWidth) * (Math.PI / 180));
// if ((TElevationDomain[X[i], Y[i] + (a - 1)] >= maxDomainDepth + WaterLevel + (WetDryThreshold * WetDryThreshold)))
// {
// TElevationDomain[X[i], Y[i] + a] = (maxDomainDepth + WaterLevel + WetDryThreshold);
// TElevationCS[X[i], Y[i] + a] = (DomainDepthCS[X[i], Y[i] + a] - TElevationDomain[X[i], Y[i] + a]);
// Volume[X[i], Y[i] + a] = TElevationCS[X[i], Y[i] + a] * (CellWidth * CellWidth);
// AboveWater[X[i], Y[i] + a] = 1;
// //repeat2 = 1;
// //a++;
// //if (a + Y[i] >= ymax)
// //{
// // repeat2 = 0;
// //}
// }
// //else
// //{
// // repeat2 = 0;
// //}
// }
// //Y[i] = Y[i] + a;
// //a = 1;
// //repeat = 0;
// else if (TElevationDomain[X[i], Y[i]] < maxDomainDepth + WaterLevel + WetDryThreshold)
// {
// if (TElevationDomain[X[i], Y[i]] >= maxDomainDepth + WaterLevel - WetDryThreshold)
// {
// AboveWater[X[i], Y[i]] = 1; // Still remains the coastline cell, it is still above the water, but not completely
// //repeat = 0;
// }
// else if (TElevationDomain[X[i], Y[i]] < maxDomainDepth + WaterLevel - WetDryThreshold)
// {
// AboveWater[X[i], Y[i]] = 0;
// TElevationCS[X[i], Y[i]] = 0;
// TElevationDomain[X[i], Y[i]] = DomainDepthCS[X[i], Y[i]];
// Volume[X[i], Y[i]] = 0;
// //Y[i] = Y[i] - 1;
// //repeat = 1;
// }
// }
// //}
//}
}
// Sources and Sinks
void DoSink()
{
// Empties of sand any cell that has been designated a sink
int s, i;
int foundOne = 0;
if (HaveSinks == 0 || RandZeroToOne() > Sinkiness)
{
return;
}
if (ColumnSinks == 1)
// Treat sink as any beach cell at a particular y-value
{
for (s = 0; s < NumSinks; s++)
{
for (i = 0; i < MaxBeachLength; i++)
{
if (X[i] == SinkX[s])
{
//PercentFullSand[X[i], Y[i]] = 0.0;
Volume[X[i], Y[i]] = 0.0;
foundOne = 1;
}
}
}
}
else
{
// Treat sink as a specific cell; empty it if it is on the beach
for (s = 0; s < NumSinks; s++)
{
for (i = 0; i < MaxBeachLength; i++)
{
if (X[i] == SinkX[s] && Y[i] == SinkY[s])
{
//PercentFullSand[X[i], Y[i]] = 0.0;
Volume[X[i], Y[i]] = 0.0;
foundOne = 1;
}
}
}
}
}
void DoSource()
{
// Adds sediment from external sources to specified cells
int s, i;
int foundOne = 0;
double sandvol;
if (ColumnSources == 1)
// Treat source as any beach cell at a particular y-value
{
for (s = 0; s < NumSources; s++)
{
for (i = 0; i < MaxBeachLength; i++)
{
if (X[i] == SourceX[s])
{
//find initial cell volume from PercentFullSand
//PercentFullSand[X[i], Y[i]] = 1;
Volume[X[i], Y[i]] += 0.001;
foundOne = 1;
}
}
}
}
else
{
// Treat source as a specific cell; add some sediment if it is on the beach
for (s = 0; s < NumSources; s++)
{
for (i = 0; i < MaxBeachLength; i++)
{
if (X[i] == SourceX[s] && Y[i] == SourceY[s])
{
////find initial cell volume from PercentFullSand
//sandvol = (PercentFullSand[X[i], Y[i]] * 2500);
////add source sand
//sandvol += 100;
////calculate new PercentFullSand
//PercentFullSand[X[i], Y[i]] = (sandvol / 2500);
//foundOne = 1;
// Little fudgey, need to work this out better later
Volume[X[i], Y[i]] += (5 * CellWidth * CellWidth);
foundOne = 1;
}
}
}
}
}
//Shadow
void ShadowSweep()
{
// Moves along beach and tests to see if cells are in shadow
// This function will use and determine the Global array: InShadow[]
// This function will use and adjust the variable: ShadowYMax
// This function will use but not adjust the variable: TotalBeachCells
// Find maximum extent of beach to use as a limit for shadow searching
// ShadowYMax = XMaxBeach(ShadowYMax) + 3;
// if(ShadowYMax > Xmax) ShadowYMax = Xmax; RCL
// Determine if beach cells are in shadow
int i;
for (i = 0; i <= TotalBeachCells; i++)
{
InShadow[i] = FindIfInShadow(X[i], Y[i], ShadowYMax);
}
//ShadowSweep_domain();
}
char FindIfInShadow(int xin, int yin, int ShadMax)
{
//Function to determine if particular cell xin,yin is in shadow
//Returns a character 'y' or 'n' to indicate
//This function will use but not affect the global arrays:
//AllBeach[][] and PercentFull[][]
//This function refers to global variables: WaveAngle, ShadowStepDistance
double xdistance, ydistance;
int xcheck = xin;
int ycheck = yin;
int iteration = 1;
while ((ycheck < ShadMax) && (xcheck > -1) && (xcheck < (pbEnd)))
{
// Find a cell along the projection line moving against wave direction
ydistance = iteration * ShadowStepDistance * Math.Cos(WaveAngle);
ycheck = yin + (int)Math.Round(ydistance);
xdistance = -iteration * ShadowStepDistance * Math.Sin(WaveAngle);
xcheck = xin + (int)Math.Round(xdistance);
if (ycheck >= ymax - 1 || xcheck >= pbEnd - 1)
{
return 'n';
}
if (ycheck < 0 || xcheck < 0)
{
return 'n';
}
if ((AboveWater[xcheck, ycheck] == 1)
&& (((ycheck + 1) > (yin + (AboveWater[xin, yin]) + Math.Abs((xcheck - xin) / Math.Tan(WaveAngle)))))
&& (xcheck > -1) && (xcheck < pbEnd - 1))
{
return 'y';
}
// Compare a partially full cell's x - distance to a line projected from the starting beach cell's x-distance
// This assumes that beach projection is in x-direction (not too bad)
// RCL this could be contributing to the jaggedness...need to take into account the way it's facingor could just ignore partially full cells completely...
iteration++;
}
// No shadow was found
return 'n';
//int Shadow_direction = -9999; // 1 = left, 2 = top left, 3 = top, 4 = top right, 5 = right
//if (WaveAngle >= 0 && WaveAngle <= 0.261799388)
//{
// Shadow_direction = 1;
//}
//else if (WaveAngle > 0.261799388 && WaveAngle <= 1.309)
//{
// Shadow_direction = 2;
//}
//else if ((WaveAngle > 1.309 && WaveAngle <= 1.6) || (WaveAngle > -1.6 && WaveAngle < -1.309))
//{
// Shadow_direction = 3;
//}
//else if (WaveAngle >= -1.309 && WaveAngle < -0.261799)
//{
// Shadow_direction = 4;
//}
//else if (WaveAngle >= -0.261799 && WaveAngle <= 0)
//{
// Shadow_direction = 5;
//}
//else
//{
//}
//int a = 1;
//int flag = 0;
//if (Shadow_direction == 1)
//{
// while (X[xin] - a > 0 && flag == 0)
// {
// if (AboveWater[X[xin] - a, Y[yin]] == 1)
// {
// flag = 1;
// }
// a++;
// }
//}
//else if (Shadow_direction == 2)
//{
// while (X[xin] - a > 0 && Y[yin] + a < ymax && flag == 0)
// {
// if (AboveWater[X[xin] - a, Y[yin] + a] == 1)
// {
// flag = 1;
// }
// a++;
// }
//}
//else if (Shadow_direction == 3)
//{
// a += 2;
// while (Y[yin] + a < ymax && flag == 0)
// {
// if (AboveWater[X[xin], Y[yin] + a] == 1)
// {
// flag = 1;
// }
// a++;
// }
//}
//else if (Shadow_direction == 4)
//{
// while (X[xin] + a > 0 && Y[yin] + a < ymax && flag == 0)
// {
// if (AboveWater[X[xin] + a, Y[yin] + a] == 1)
// {
// flag = 1;
// }
// a++;
// }
//}
//else if (Shadow_direction == 5)
//{
// while (X[xin] + a > 0 && flag == 0)
// {
// if (AboveWater[X[xin] + a, Y[yin]] == 1)
// {
// flag = 1;
// }
// a++;
// }
//}
//if (flag == 1)
//{
// return 'y';
//}
//return 'n';
}
void ShadowSweep_domain()
{
// Moves along beach and tests to see if cells are in shadow
// This function will use and determine the Global array: InShadow[]
// This function will use and adjust the variable: ShadowYMax
// This function will use but not adjust the variable: TotalBeachCells
// Find maximum extent of beach to use as a limit for shadow searching
// ShadowYMax = XMaxBeach(ShadowYMax) + 3;
// if(ShadowYMax > Xmax) ShadowYMax = Xmax; RCL
// Determine if beach cells are in shadow
int i;
Array.Clear(InShadow_domain, 0, InShadow_domain.Length);
for (int x = 0; x < pbEnd; x++)
{
for (int y = 0; y < ymax; y++)
{
{
InShadow_domain[x, y] = FindIfInShadow_domain(x, y, ShadowYMax);
}
}
}
}
double FindIfInShadow_domain(int xin, int yin, int ShadMax)
{
//Function to determine if particular cell xin,yin is in shadow
//Returns a character 'y' or 'n' to indicate
//This function will use but not affect the global arrays:
//AllBeach[][] and PercentFull[][]
//This function refers to global variables: WaveAngle, ShadowStepDistance
double xdistance, ydistance;
int xcheck = xin;
int ycheck = yin;
int iteration = 1;
while ((ycheck < ShadMax) && (xcheck > -1) && (xcheck < (pbEnd)))
{
// Find a cell along the projection line moving against wave direction
ydistance = iteration * ShadowStepDistance * Math.Cos(WaveAngle);
ycheck = yin + (int)Math.Round(ydistance);
xdistance = -iteration * ShadowStepDistance * Math.Sin(WaveAngle);
xcheck = xin + (int)Math.Round(xdistance);
if (ycheck >= ymax - 1 || xcheck >= pbEnd - 1)
{
return 0;
}
if (ycheck < 0 || xcheck < 0)
{
return 0;
}
if ((AboveWater[xcheck, ycheck] == 1)
&& (((ycheck + 1) > (yin + (AboveWater[xin, yin]) + Math.Abs((xcheck - xin) / Math.Tan(WaveAngle)))))
&& (xcheck > -1) && (xcheck < pbEnd - 1))
{
return 1;
}
// Compare a partially full cell's x - distance to a line projected from the starting beach cell's x-distance
// This assumes that beach projection is in x-direction (not too bad)
// RCL this could be contributing to the jaggedness...need to take into account the way it's facingor could just ignore partially full cells completely...
iteration++;
}
// No shadow was found
return 0;
//int Shadow_direction = -9999; // 1 = left, 2 = top left, 3 = top, 4 = top right, 5 = right
//if (WaveAngle >= 0 && WaveAngle <= 0.261799388)
//{
// Shadow_direction = 1;
//}
//else if (WaveAngle > 0.261799388 && WaveAngle <= 1.309)
//{
// Shadow_direction = 2;
//}
//else if ((WaveAngle > 1.309 && WaveAngle <= 1.6) || (WaveAngle > -1.6 && WaveAngle < -1.309))
//{
// Shadow_direction = 3;
//}
//else if (WaveAngle >= -1.309 && WaveAngle < -0.261799)
//{
// Shadow_direction = 4;
//}
//else if (WaveAngle >= -0.261799 && WaveAngle <= 0)
//{
// Shadow_direction = 5;
//}
//else
//{
//}
//int a = 1;
//int flag = 0;
//if (Shadow_direction == 1)
//{
// while (X[xin] - a > 0 && flag == 0)
// {
// if (AboveWater[X[xin] - a, Y[yin]] == 1)
// {
// flag = 1;
// }
// a++;
// }
//}
//else if (Shadow_direction == 2)
//{
// while (X[xin] - a > 0 && Y[yin] + a < ymax && flag == 0)
// {
// if (AboveWater[X[xin] - a, Y[yin] + a] == 1)
// {
// flag = 1;
// }
// a++;
// }
//}
//else if (Shadow_direction == 3)
//{
// a += 2;
// while (Y[yin] + a < ymax && flag == 0)
// {
// if (AboveWater[X[xin], Y[yin] + a] == 1)
// {
// flag = 1;
// }
// a++;
// }
//}
//else if (Shadow_direction == 4)
//{
// while (X[xin] + a > 0 && Y[yin] + a < ymax && flag == 0)
// {
// if (AboveWater[X[xin] + a, Y[yin] + a] == 1)
// {
// flag = 1;
// }
// a++;
// }
//}
//else if (Shadow_direction == 5)
//{
// while (X[xin] + a > 0 && flag == 0)
// {
// if (AboveWater[X[xin] + a, Y[yin]] == 1)
// {
// flag = 1;
// }
// a++;
// }
//}
//if (flag == 1)
//{
// return 'y';
//}
//return 'n';
}
// Calculate Overwash
void CheckOverwashSweep()
{
// Just a loop to call overwash check founction CheckOverwash
// Nothing done here, but can be down when CheckOVerwash is called
int i, ii;
int sweepsign;
if (RandZeroToOne() * 2 > 1)
{
sweepsign = 1;
}
else
{
sweepsign = 0;
}
OWflag = 0;
for (i = 0; i < TotalBeachCells - 1; i++)
{
if (sweepsign == 1)
{
ii = i;
}
else
{
ii = TotalBeachCells - 1 - i;
}
// To do test shoreline should be facing seaward
// don't worry about shadow here, as overwash is not set to a time scale with AST
if ((Math.Abs(SurroundingAngle[ii]) < (OverwashLimit / radtodeg)) && (InShadow[ii] == 'n'))
{
CheckOverwash(ii);
}
}
}
void CheckOverwash(int icheck)
{
// Step back pixelwise in direction of SurroundingAngle[] to check 'needage' (?)
// icheck is passed from CheckOverwashSweep() and is the index of the shoreline cell being checked for overwash
// Calls DoOverwash(). 'x' and 'y' hold real-space (floating point) values, and will be mapped onto integer array
double slope; // slope of zero goes staight back
int xsign; // holder for going left or right alongshore
double x, y; // holders for 'real' location of x and y
double xin, yin; // starting 'real' locations
int xtest, ytest; // cell looking at
double xint, yint; // intercepts of overwash line in overwashable cell
int NextXInt, NextYInt; // holder vairables for cell to check
double Xdown, DistanceDown; // when going to next x cell, what other values
double Yside, DistanceSide; // when gpoing to next y cell,other values
double checkdistance; // distance of checking line- minimum, not actual width, ends loop
double measwidth; // actual barrier width between cells
int AllBeachFlag; // flag to see if overwash line has passed over at least one AllBeach cell
// convert angle to a slope and the direction of steps
// note that for case of shoreline, positive angle will be minus y direcyion
if (SurroundingAngle[icheck] == 0.0)
{
// unlikely, but make sure no div by zero
slope = 0.00001;
}
else if (Math.Abs(SurroundingAngle[icheck]) == 90.0)
{
slope = 9999.9;
}
else
{
slope = Math.Abs(Math.Tan(SurroundingAngle[icheck]));
}
if (SurroundingAngle[icheck] > 0)
{
xsign = 1; // check right
}
else
{
xsign = -1; // check left
}
if (AboveWater[X[icheck], Y[icheck] - 1] == 1 // if the cell below is all beach
|| ((AboveWater[X[icheck] - 1, Y[icheck]] == 1) // or if the cell to the left is all beach
&& (AboveWater[X[icheck] + 1, Y[icheck]] == 1))) // and the cell to the right is all beach
// 'regular condition'
// plus 'stuck in the middle' situation (unlikely scenario)
{
yin = Y[icheck] + AboveWater[X[icheck], Y[icheck]];
xin = X[icheck] + 0.5;
}
else if (AboveWater[X[icheck] - 1, Y[icheck]] == 1) //if the cell to the left is all beach
// on right side
{
yin = Y[icheck] + 0.5;
xin = X[icheck] + AboveWater[X[icheck], Y[icheck]];
}
else if (AboveWater[X[icheck] + 1, Y[icheck]] == 1)
// on left side
{
yin = Y[icheck] + 0.5;
xin = X[icheck] + 1.0 - AboveWater[X[icheck], Y[icheck]];
}
else
// underneath, no overwash
{
return;
}
x = xin;
y = yin;
checkdistance = 0;
AllBeachFlag = 0;
int countno = 0;
while ((checkdistance < CritBWidth) && (x > 0) && (x < pbEnd) && (y > 1))
{
NextYInt = Convert.ToInt32(Math.Ceiling(y) - 1);
if (xsign > 0)
{
NextXInt = Convert.ToInt32((int)Math.Floor(x) + 1);
}
else
{
NextXInt = Convert.ToInt32(Math.Ceiling(x - 1));
}
// Moving to next whole 'y' position, what is x position?
Xdown = x + (y - NextYInt) * slope * xsign;
DistanceDown = Raise(((Xdown - x) * (Xdown - x) + (NextYInt - y) * (NextYInt - y)), 0.5);
// Moving to next whole 'x' position, what is y position?
Yside = y - Math.Abs(NextXInt - x) / slope;
DistanceSide = Raise(((NextXInt - x) * (NextXInt - x) + (Yside - y) * (Yside - y)), 0.5);
if (DistanceDown < DistanceSide)
// Next cell is the down cell
{
y = NextYInt;
x = Xdown;
ytest = NextYInt - 1;
xtest = Convert.ToInt32(Math.Floor(x));
}
else
// Next cell is the side cell
{
y = Yside;
x = NextXInt;
ytest = Convert.ToInt32(Math.Floor(y));
xtest = Convert.ToInt32(x + (xsign - 1) / 2);
}
checkdistance = Raise(((y - yin) * (y - yin) + (x - xin) * (x - xin)), 0.5) * CellWidth;
if (xtest >= 0 && ytest >= 0 && AboveWater[xtest, ytest] == 1)
{
AllBeachFlag = 1;
}
if (xtest >= 0 && ytest >= 0 && (AllBeach[xtest, ytest] == 'n') && (AllBeachFlag == 1)) /*&& !(((Y[icheck] - ytest) > MaxFillCell) || (Math.Abs(xtest - X[icheck]) > MaxFillCell)))*/
// if passed through an allbeach and a neighboring partial cell, jump out, only bad things follow
{
return;
}
if (xtest >= 0 && ytest >= 0 && (AllBeach[xtest, ytest] == 0) && (AllBeachFlag == 1)) /*&& (ytest < Y[icheck]) && (((Y[icheck] - ytest) > MaxFillCell) || (Math.Abs(xtest - X[icheck]) > MaxFillCell)))*/
// Looking for shore cells, but don't want immediate neighbors, and go backwards
// Also mush pass though an allbeach cell along the way
{
if (AboveWater[xtest, ytest + 1] == 1)
// 'regular condition' - UNDERNEATH, here
{
yint = (ytest + 1 - AboveWater[xtest, ytest]);
xint = xin + (yin - yint) * xsign * slope;
if ((xint > xtest + 1.0) || (xint < xtest))
// This cell isn't actually an overwash cell
{
measwidth = CritBWidth;
}
else
{
measwidth = CellWidth * Raise((yint - yin) * (yint - yin) + (xint - xin) * (xint - xin), 0.5);
}
}
else if (AboveWater[xtest - 1, ytest] == 1)
// On right side
{
xint = (xtest + AboveWater[xtest, ytest]);
yint = yin - Math.Abs(xin - xint) / slope;
if (yint < ytest)
// This cell isn't actually an overwash cell
{
measwidth = CritBWidth;
}
else
{
measwidth = CellWidth * Raise((yint - yin) * (yint - yin) + (xint - xin) * (xint - xin), 0.5);
}
}
else if (AboveWater[xtest + 1, ytest] == 1)
// on left side
{
xint = (xtest + 1 - AboveWater[xtest, ytest]);
yint = yin - Math.Abs(xin - xint) / slope;
if (yint < ytest)
// This cell isn't actually an overwash cell
{
measwidth = CritBWidth;
}
else
{
measwidth = CellWidth * Raise((yint - yin) * (yint - yin) + (xint - xin) * (xint - xin), 0.5);
}
}
else if (AboveWater[xtest, ytest - 1] == 1)
// 'regular condition'
// plus 'stuck in the middle' situation
{
yint = (ytest + AboveWater[xtest, ytest]);
xint = xin + (yin - yint) * xsign * slope;
if ((xint > xtest + 1.0) || (xint < xtest))
// This cell isn't actually an overwash cell
{
measwidth = CritBWidth;
}
else
{
measwidth = CellWidth * Raise((yint - yin) * (yint - yin) + (xint - xin) * (xint - xin), 0.5);
}
}
else if (AboveWater[xtest, ytest] > 0)
// uh oh - not good situation, no allbeach on sides
// assume this is an empty cell
{
xint = x;
yint = y;
measwidth = CellWidth * Raise((yint - yin) * (yint - yin) + (xint - xin) * (xint - xin), 0.5);
}
else
// empty cell - oughta fill 'er up - fill max barrier width
{
xint = x;
yint = y;
measwidth = CritBWidth - CellWidth;
}
checkdistance = measwidth;
if (measwidth < CritBWidth)
{
DoOverwash(X[icheck], Y[icheck], xtest, ytest, xint, yint, measwidth, icheck);
// jump out of loop
OWflag = 1;
return;
}
}
countno++;
}
}
void DoOverwash(int xfrom, int yfrom, int xto, int yto, double xintto, double yintto, double widthin, int ishore)
{
// Given a cell where overwash is needed ,move sediment back
// for 'true' overwash based on shoreline angles will change and use PercentFull[][] and AllBeach [][]
double BBneed, delBB, delShore;
double DepthBB; // holds effective backbarrier depth
DepthBB = GetOverwashDepth(xto, yto, xintto, yintto, ishore);
// Calculated value of most that backbarrier can move given geometry (true, non-iterative solution)
if (DepthBB == DepthShoreface)
{
BBneed = MaxOver;
}
else
{
BBneed = (CritBWidth - widthin) / CellWidth / (1 - (DepthBB / DepthShoreface));
}
if (BBneed <= MaxOver)
// do all overwash
{
delShore = BBneed * DepthBB / DepthShoreface;
delBB = BBneed;
}
else
// only do overwash to max change)
{
delShore = MaxOver * DepthBB / DepthShoreface;
delBB = MaxOver;
}
Volume[xto, yto] += delBB * CellWidth * DepthShelf[xto, yto];
Volume[xfrom, yfrom] -= delShore * CellWidth * DepthShelf[xfrom, yfrom];
}
double GetOverwashDepth(int xin, int yin, double xinfl, double yinfl, int ishore)
{
// Rountine finds corresponding overwash depths
// OWType = 0 take the depth at neightbor to the backing cell
// OWType = 1 geometric rule based upon distance from back to shoreline
{
int ydepth;
double Depth;
double BBDistance; // Distance from backshore to next shore
double slope; // slope of zero goes staight back
int xsign; // holder for going left or right alongshore
double x, y; // holders for 'real' location of x and y
int xtest = 0; // cell looking at
int ytest = 0; // cell looking at
int NextXInt, NextYInt; // holder variables for cell to check
double Xdown, DistanceDown; // when going to next x cell, what other values
double Yside, DistanceSide; // when gpoing to next y cell,other values
int BackFlag; // Flag to indicate if hit backbarrier
int Backi = -1; // i for backbarrier intersection
int i, j; // counters
int FoundFlag; // Backbarrier intersection flag
double AngleSin, AngleUsed;
if (OWType == 0)
// Use Cell Depths for overwash depths
{
ydepth = yin;
//Depth = CellDepth[xin, ydepth];
Depth = TElevationCS[xin, ydepth];
while ((Depth < 0) && (ydepth > 0))
{
//Depth = CellDepth[xin, ydepth];
Depth = TElevationCS[xin, ydepth];
ydepth--;
}
if (Depth == DepthShoreface)
{
Depth = 6.0;
}
return Depth;
}
else if (OWType == 1)
// Geometric relation to determine depth through intersection of shorefaces
// look in line determined by shoreline slope - reuse stepping function (again)
{
x = xinfl;
y = yinfl;
if (SurroundingAngle[ishore] == 0.0)
{
// unlikely, but make sure no div by zero
slope = 0.00001;
}
else if (Math.Abs(SurroundingAngle[ishore]) == 90.0)
{
slope = 9999.9;
}
else
{
slope = Math.Abs(Math.Tan(SurroundingAngle[ishore]));
}
BackFlag = 0;
if (SurroundingAngle[ishore] > 0)
{
xsign = 1;
}
else
xsign = -1;
while ((BackFlag == 0) && (x > 1) && (x < pbEnd) && (y > 1))
{
NextYInt = ((int)Math.Ceiling(y) - 1);
if (xsign > 0)
{
NextXInt = ((int)Math.Floor(x) + 1);
}
else
{
NextXInt = ((int)Math.Ceiling(x - 1));
}
// moving to next whole 'x' position, what is y position?
Xdown = x + (y - NextYInt) * slope * xsign;
DistanceDown = Raise(((Xdown - x) * (Xdown - x) + (NextYInt - y) * (NextYInt - y)), 0.5);
// moving to next whole 'y' position, what is x position?
Yside = y - Math.Abs(NextXInt - x) / slope;
DistanceSide = Raise(((NextXInt - x) * (NextXInt - x) + (Yside - y) * (Yside - y)), 0.5);
// next cell is the down cell
if (DistanceDown < DistanceSide)
{
y = NextYInt;
x = Xdown;
ytest = NextYInt - 1;
xtest = ((int)Math.Floor(x));
}
// next cell is the side cell
else
{
y = Yside;
x = NextXInt;
ytest = ((int)Math.Floor(y));
xtest = ((int)x + (xsign - 1) / 2);
}
if (AboveWater[xtest, ytest] > 0)
{
BackFlag = 1;
}
}
// Try to find the i for the cell found
// If you have a better idea how to do this, go ahead
i = 2;
FoundFlag = 0;
while ((i < TotalBeachCells - 1) && (FoundFlag == 0))
{
if ((Y[i] == ytest) && (X[i] == xtest))
{
FoundFlag = 1;
Backi = i;
}
i++;
}
if (BackFlag == 0)
// The search for the backbarrier went out of bounds - not good, assume big = depthshoreface
// Periodic B.C.'s should make this not so important
{
Depth = DepthShoreface;
}
else
{
BBDistance = Raise(((yinfl - ytest - AboveWater[xtest, ytest]) * (yinfl - ytest - AboveWater[xtest, ytest])) + ((xinfl - xtest - 0.5) * (xinfl - xtest - 0.5)), 0.5);
if (FoundFlag == 0)
// The backbarrier intersection isn't on the shoreline
// Assume 1/2 of the length applies to this case
{
Depth = BBDistance / 2 * ShorefaceSlope * CellWidth;
}
else
// Use the fancy geometry thing
{
AngleUsed = 0;
for (j = -1; j < 2; j++)
{
AngleUsed += SurroundingAngle[Backi + j];
}
AngleUsed = AngleUsed / 5;
if (Math.Abs(AngleUsed) > pi / 4.0)
{
AngleUsed = pi / 4.0;
}
AngleSin = Math.Sin(pi / 2.0 - Math.Abs(SurroundingAngle[ishore] + AngleUsed));
Depth = BBDistance * AngleSin / (1 + AngleSin);
}
}
if (Depth < OWMinDepth)
{
Depth = OWMinDepth;
}
else if (Depth > DepthShoreface)
{
Depth = DepthShoreface;
}
return Depth;
}
PauseRun(xin, yin, -1);
return DepthShoreface;
}
}
// Misc Equations
static double copysign(double x, double y)
{
if (Math.Sign(x) != Math.Sign(y))
{
return x *= -1;
}
return x;
}
double Raise(double b, double e)
{
// Function calulates b to the e power. pow has problems if b <= 0
// Note you can't use this at all when b is negative--it'll be wrong in cases when the answer returned should have been positive, as x^2 when x < 0.
if (b > 0)
{
return Math.Pow(b, e);
}
else
{
PauseRun(-1, -1, -1);
return 0;
}
}
double RandZeroToOne()
{
// Returns a random number between zero and one
Random rand = new Random();
double RandNo = rand.Next(0, 1000);
RandNo = ((RandNo + 1) / 1000);
return RandNo;
}
void ZeroVars()
{
// Resets all arrays recalculated at each time step to 'zero' conditions
int z;
int x,y;
for (z = 0; z <= (MaxBeachLength-1); z++)
{
X[z] = -1;
Y[z] = -1;
XRock[z] = -1;
YRock[z] = -1;
XBehind[z] = -1;
YBehind[z] = -1;
XRockBehind[z] = -1;
YRockBehind[z] = -1;
InShadow[z] = '?';
ShorelineAngle[z] = -999;
UpWind[z] = '?';
VolumeAcrossBorder[z] = 0.0;
ActualVolumeAcross[z] = 0.0;
}
}
// Save Functions
void SaveImageFunct()
{
int RockCheck = 1; // Need all three to be checked for JPEG - need to sort this later!
int SandCheck = 1; // 1 = checked, 0 = not checked
int XYCheck = 1; // This is so they can be changed back after
updateGraphics_Click_1(updateGraphicsButton, EventArgs.Empty);
// Save image
// Batch
if (autorestart == 1)
{
m_objDrawingSurface.MakeTransparent();
m_objDrawingSurface.Save("OUTPUT_FILES/Run_" + Restart_count + "/Simulation/" + savefilename + "_" + imageCount + ".png", System.Drawing.Imaging.ImageFormat.Png);
}
else
{
m_objDrawingSurface.MakeTransparent();
m_objDrawingSurface.Save("OUTPUT_FILES/Simulation/" + savefilename + "_" + imageCount + ".png", System.Drawing.Imaging.ImageFormat.Png);
}
// Output Arrays too...
int x, y;
imageCount++;
}
void SaveLineToFile()
{
//// Saves data line of shoreline position rather than entire array
//// Main concern is to have only one data point at each alongshore location
//// Save file name will add extension '.' and the TimeStepValue
//int y, x, xtop, i;
//double xsave;
//string fileName = Convert.ToString(counter / SaveSpacing);
////MessageBox.Show("Saving Line to File \n Saving as: " + "TEST_FILES/" + fileName + ".out");
//StreamWriter saveLineFile = new StreamWriter("OUTPUT_FILES/Simulation/" + fileName + ".out");
//for (y = 0; y < ymax; y++)
//{
// x = xDisplayStart;
// xtop = xmax;
// // Step back to where we encounter allbeach
// while (AllBeach[x, y] == 0)
// {
// x -= 1;
// }
// // If on side of shape, need to average
// if (PercentFullSand[x + 2, y] > 0)
// {
// xtop = x + 1;
// while (PercentFullSand[xtop, y] > 0)
// {
// xtop += 1;
// }
// xsave = x;
// for (i = x + 1; i < xtop; i++)
// {
// xsave += PercentFullSand[i, y];
// }
// }
// // Otherwise Regular Beach Condition
// else
// {
// xsave = x + PercentFullSand[x + 1, y];
// }
// // note this assumes average of beach locations should be 0.5 percentfull
// saveLineFile.Write(xsave - InitBeach + 0.5);
//}
//saveLineFile.Close();
////MessageBox.Show("Line file saved!");
}
void SaveSandToFile()
{
////Saves current AllBeach[][] and PercentFullSand[][] data arrays to file
////Save file name will add extension '.' and the TimeStepValue
////LMV - Save AllRock[][], PercentFullRock[][], TypeOfRock[][]
//int x, y;
//StreamWriter saveSandFile = new StreamWriter("OUTPUT_FILES/Sand" + "Sand" + "_" + counter + ".out");
//if (SaveFile == 1)
//{
// for (y = 0; y < ymax; y++)
// {
// for (x = xDisplayStart; x < xDisplayEnd; x++)
// {
// saveSandFile.Write(TypeOfRock[x, y]);
// }
// }
// for (y = 0; y < ymax; y++)
// {
// for (x = xDisplayStart; x < xDisplayEnd; x++)
// {
// saveSandFile.Write(PercentFullRock[x, y]);
// }
// }
// for (y = 0; y < ymax; y++)
// {
// for (x = xDisplayStart; x < xDisplayEnd; x++)
// {
// saveSandFile.Write(PercentFullSand[x, y]);
// }
// }
// if (SaveAge == 1)
// {
// for (y = 0; y < ymax; y++)
// {
// for (x = xDisplayStart; x < xDisplayEnd; x++)
// {
// saveSandFile.Write(Age[x, y]);
// }
// }
// }
//}
////Array output
//if (SaveFile == 2)
//{
// for (y = ymax - 1; y >= 0; y--)
// {
// for (x = xDisplayStart; x < xDisplayEnd; x++)
// {
// saveSandFile.Write(TypeOfRock[x, y]);
// }
// saveSandFile.Write(Environment.NewLine);
// }
// for (y = ymax - 1; y >= 0; y--)
// {
// for (x = xDisplayStart; x < xDisplayEnd; x++)
// {
// saveSandFile.Write(PercentFullRock[x, y]);
// }
// saveSandFile.Write(Environment.NewLine);
// }
// for (y = ymax - 1; y >= 0; y--)
// {
// for (x = xDisplayStart; x < xDisplayEnd; x++)
// {
// saveSandFile.Write(PercentFullSand[x, y]);
// }
// saveSandFile.Write(Environment.NewLine);
// }
// if (SaveAge == 1)
// {
// for (y = ymax - 1; y >= 0; y--)
// {
// for (x = xDisplayStart; x < xDisplayEnd; x++)
// {
// saveSandFile.Write(Age[x, y]);
// }
// saveSandFile.Write(Environment.NewLine);
// }
// }
//}
//saveSandFile.Close();
}
void SandOutput()
{
int x, y;
double SandAmount = 0;
string MovedSedVolPath = "OUTPUT_FILES/MovedSedVol.dat";
StreamWriter TDomain = new StreamWriter("OUTPUT_FILES/TDomain.out");
for (y = ymax - 1; y >= 0; y--)
{
for (x = 0; x < pbEnd; x++)
{
//SandAmount += (Volume[x, y]);
TDomain.Write(TElevationDomain[x, y] + " ");
}
TDomain.Write(Environment.NewLine);
}
TDomain.Close();
StreamWriter SandAmountFile = new StreamWriter(MovedSedVolPath);
SandAmountFile.Write(counter + " " + SandAmount + Environment.NewLine);
SandAmountFile.Close();
SandAmount = 0;
}
void WaveOutFile()
{
StreamWriter WaveFileOutput;
if(counter == 0)
{
WaveFileOutput = new StreamWriter(wavesavename);
WaveFileOutput.WriteLine(WaveAngle + " " + Period + " " + OffShoreWvHt);
}
else
{
WaveFileOutput = File.AppendText(wavesavename);
WaveFileOutput.WriteLine((-WaveAngle * radtodeg) + " " + Period + " " + OffShoreWvHt);
//WaveFileOutput.WriteLine(WaveAngle + " " + Period + " " + OffShoreWvHt);
}
WaveFileOutput.Close();
}
void MetaFile()
{
// Input Wave Distribution
StreamWriter metaFile = new StreamWriter("OUTPUT_FILES/metaFile.out");
metaFile.WriteLine("OffShoreWvHt = " + OffShoreWvHt);
metaFile.WriteLine("Period = " + Period);
metaFile.WriteLine("Asym = " + Asym);
metaFile.WriteLine("Highness = " + (1 - Highness));
metaFile.WriteLine("TimeStepValue (counter) = " + counter);
metaFile.WriteLine("Duration = " + Duration);
metaFile.WriteLine("SlowWeatherCoeff = " + SlowWeatherCoeff);
metaFile.WriteLine("FastWeatherCoeff = " + FastWeatherCoeff);
metaFile.WriteLine("PercentFineFast = " + PercentFineFast);
metaFile.WriteLine("PercentFineSlow = " + PercentFineSlow);
metaFile.WriteLine("ErosionRatePerYear = " + ErosionRatePerYear);
metaFile.WriteLine("coastrotation = " + coastrotation);
metaFile.WriteLine("waveheightchange = " + waveheightchange);
metaFile.WriteLine("waveperiodchange = " + waveperiodchange);
metaFile.Close();
}
void ResultsData()
{
//
// CM - records data used for analysing evolution of the coastline
// Each piece of data has it's own file with timestamp
//
string filelocation_results;
if (autorestart == 1)
{
Directory.CreateDirectory("OUTPUT_FILES/Run_" + Restart_count + "/Results");
filelocation_results = "OUTPUT_FILES/Run_" + Restart_count + "/Results/";
}
else
{
Directory.CreateDirectory("OUTPUT_FILES/Results");
filelocation_results = "OUTPUT_FILES/Results/";
}
// Water
StreamWriter Water;
if (counter == 0)
{
Water = new StreamWriter(filelocation_results + "Water.out");
Water.WriteLine(counter + " " + Asym + " " + Highness + " Counter asym highness");
Water.WriteLine(counter + " " + WaterLevel + " " + HighWaterHeight + " Counter Tideslow Tidehigh");
Water.WriteLine(counter + " " + SLR + " " + SLRrate + " Counter SLR SLRrate");
Water.WriteLine(counter + " " + maxDomainDepth + " " + WDThreshold + " Counter MaxDomaiDepth WDThreshold");
Water.Write(Environment.NewLine);
Water.WriteLine("Counter WaterLevel");
Water.WriteLine(counter + " " + WaterLevel);
Water.Close();
}
else
{
Water = File.AppendText(filelocation_results + "Water.out");
Water.WriteLine(counter + " " + WaterLevel + " " + Asym + " " + Highness);
Water.Close();
}
// Sinuosity
StreamWriter Sinuosity;
double sinuosity = (double)TotalBeachCells / pbEnd;
if (counter == 0)
{
Sinuosity = new StreamWriter(filelocation_results + "Sinuosity.out");
Sinuosity.WriteLine("Counter Sinuosity");
Sinuosity.WriteLine(counter + " " + sinuosity);
Sinuosity.Close();
}
else
{
Sinuosity = File.AppendText(filelocation_results + "Sinuosity.out");
Sinuosity.WriteLine(counter + " " + sinuosity);
Sinuosity.Close();
}
// Volume Wet-Dry
StreamWriter above_water = new StreamWriter(filelocation_results + "above_water.out");
StreamWriter Volume_File = new StreamWriter(filelocation_results + "Volume.out");
int y_it = 0;
int x_it = 0;
for (y_it = 0; y_it < ymax; y_it++)
{
for (x_it = 0; x_it < pbEnd; x_it++)
{
if (AboveWater[x_it, y_it] == 1)
{
Vol_Dry += Volume[x_it, y_it];
Cells_Dry++;
}
else if (AboveWater[x_it, y_it] == 0)
{
Vol_Wet += Volume[x_it, y_it];
Cells_Wet++;
}
else
{
}
above_water.Write(AboveWater[x_it, y_it] + " ");
Volume_File.Write(Volume[x_it, y_it] + " ");
}
above_water.Write(Environment.NewLine);
Volume_File.Write(Environment.NewLine);
}
above_water.Close();
Volume_File.Close();
StreamWriter Vol_WetDry;
if (counter == 0)
{
StreamWriter cs_elev = new StreamWriter(filelocation_results + "cs_elev.out");
for (int cs_Y = ymax - 1; cs_Y >= 0; cs_Y--)
{
for (int cs_X = 0; cs_X < pbEnd; cs_X++)
{
cs_elev.Write(Volume[cs_X, cs_Y] + " ");
}
cs_elev.Write(Environment.NewLine);
}
cs_elev.Close();
double starting_pert_cells = 96; // Taking from DEM, need to change if change DEM!!
double starting_pert_vol = 149580000; // Taking from DEM, need to change if change DEM!!
Start_Vol_Wet = Vol_Wet + starting_pert_vol;
Start_Cells_Wet = Cells_Wet + starting_pert_cells;
Start_Vol_Dry = Vol_Dry - starting_pert_vol;
Start_Cells_Dry = Cells_Dry - starting_pert_cells;
Vol_WetDry = new StreamWriter(filelocation_results + "Vol_WetDry.out");
Vol_WetDry.WriteLine("Counter StartCount_Pert StartVol_Pert");
Vol_WetDry.WriteLine(counter + " " + starting_pert_cells + " " + starting_pert_vol);
Vol_WetDry.WriteLine(Environment.NewLine);
Vol_WetDry.WriteLine("Counter CellsWet VolWet CellsDry VolDry");
Vol_WetDry.WriteLine(counter + " " + Cells_Wet + " " + Vol_Wet + " " + Cells_Dry + " " + Vol_Dry);
Vol_WetDry.Close();
}
else
{
Vol_WetDry = File.AppendText(filelocation_results + "Vol_WetDry.out");
Vol_WetDry.WriteLine(counter + " " + Cells_Wet + " " + Vol_Wet + " " + Cells_Dry + " " + Vol_Dry);
Vol_WetDry.Close();
}
// Shoreface Slope (Linear Regression)
int xx = 0;
double[] SF_Slope = new double[4];
double SF_Average = 0;
for (int repeat = 0; repeat < 4; repeat++)
{
double SumX = 0;
double SumY = 0;
double SumXY = 0;
double SumX2 = 0;
double SumY2 = 0;
int xcount = 0;
int yy = ymax - 2;
xx += pbEnd / 5;
while (AboveWater[xx, yy] == 0)
{
xcount++;
SumX += CellWidth * xcount;
SumY += TElevationDomain[xx, yy];
SumXY += (CellWidth * xcount) * (TElevationDomain[xx, yy]);
SumX2 += (CellWidth * xcount) * (CellWidth * xcount);
SumY2 += (TElevationDomain[xx, yy] * TElevationDomain[xx, yy]);
yy--;
}
SF_Slope[repeat] = (((xcount * SumXY) - (SumX * SumY)) / ((xcount * SumX2) - (SumX * SumX)));
}
for (int i = 0; i < 4; i++)
{
SF_Average += SF_Slope[i];
}
SF_Average /= 4;
StreamWriter SFS;
if (counter == 0)
{
SFS = new StreamWriter(filelocation_results + "SF_Slope.out");
SFS.WriteLine("Counter ShorefaceSlope");
SFS.WriteLine(counter + " " + SF_Average);
SFS.Close();
}
else
{
SFS = File.AppendText(filelocation_results + "SF_Slope.out");
SFS.WriteLine(counter + " " + SF_Average);
SFS.Close();
}
// Local Beach Slope
int xxx = 0;
double[] B_Slope = new double[4];
double B_Average = 0;
for (int repeat = 0; repeat < 4; repeat++)
{
double SumX = 0;
double SumY = 0;
double SumXY = 0;
double SumX2 = 0;
double SumY2 = 0;
int xcount = 0;
int yy = 3;
xxx += pbEnd / 5;
while (AboveWater[xxx, yy] == 1)
{
xcount++;
SumX += CellWidth * xcount;
SumY += TElevationDomain[xxx, yy];
SumXY += (CellWidth * xcount) * (TElevationDomain[xxx, yy]);
SumX2 += (CellWidth * xcount) * (CellWidth * xcount);
SumY2 += (TElevationDomain[xxx, yy] * TElevationDomain[xxx, yy]);
yy++;
}
B_Slope[repeat] = (((xcount * SumXY) - (SumX * SumY)) / ((xcount * SumX2) - (SumX * SumX)));
}
for (int i = 0; i < 4; i++)
{
B_Average += B_Slope[i];
}
B_Average = (B_Average / 4) * -1;
StreamWriter B_slope;
if (counter == 0)
{
B_slope = new StreamWriter(filelocation_results + "B_Slope.out");
B_slope.WriteLine("Counter BeachSlope");
B_slope.WriteLine(counter + " " + B_Average);
B_slope.Close();
}
else
{
B_slope = File.AppendText(filelocation_results + "B_Slope.out");
B_slope.WriteLine(counter + " " + B_Average);
B_slope.Close();
}
// Net Erosion/Accretion
StreamWriter XY_array;
if (counter == 0)
{
XY_array = new StreamWriter(filelocation_results + "XY_array.out");
XY_array.WriteLine("Counter i X Y");
for (int i = 0; i < TotalBeachCells; i++)
{
XY_array.WriteLine(counter + " " + i + " " + X[i] + " " + Y[i]);
}
XY_array.WriteLine(Environment.NewLine);
XY_array.Close();
}
else
{
XY_array = File.AppendText(filelocation_results + "XY_array.out");
for (int i = 0; i < TotalBeachCells; i++)
{
XY_array.WriteLine(counter + " " + i + " " + X[i] + " " + Y[i]);
}
XY_array.WriteLine(Environment.NewLine);
XY_array.Close();
}
// Lifecycle of features
int flag_lifecycle = 0;
int flag_prevpeak = 0;
int flag_its = 0;
int Peak_count = 0;
double CrossShore = 0; // How far into the sea do the features project?
double LongShore = 0; // How far/rate of longshore movement
for (int Yy = ymax - 3; Yy > 2; Yy--)
{
for (int Xx = 4; Xx < pbEnd - 2; Xx++)
{
if (AboveWater[Xx, Yy] == 1 && flag_lifecycle == 0)
{
CrossShore = Yy;
LongShore = Xx;
flag_lifecycle = 1;
flag_its++;
Peak_count = 1;
}
else if (AboveWater[Xx, Yy] == 1 && flag_lifecycle == 1 && AboveWater[Xx - 1, Yy] == 0 && AboveWater[Xx - 2, Yy] == 0 && AboveWater[Xx - 3, Yy] == 0)
{
Peak_count += 1;
}
}
if (flag_lifecycle == 1)
{
if (flag_its == 1 && Peak_count < 3 || Peak_count > flag_prevpeak)
{
// Look at the next row down
// Likely to have caught only one of the peaks, just check!
flag_prevpeak = Peak_count;
Peak_count = 0;
}
else if (Peak_count < flag_prevpeak)
{
Peak_count = flag_prevpeak;
break;
}
else
{
break;
}
}
}
StreamWriter Lifecycle;
if (counter == 0)
{
Lifecycle = new StreamWriter(filelocation_results + "Lifecycle.out");
Lifecycle.WriteLine("Counter CrossShore Longshore Peak_count");
Lifecycle.WriteLine(counter + " " + CrossShore + " " + LongShore + " " + Peak_count);
Lifecycle.Close();
}
else
{
Lifecycle = File.AppendText(filelocation_results + "Lifecycle.out");
Lifecycle.WriteLine(counter + " " + CrossShore + " " + LongShore + " " + Peak_count);
Lifecycle.Close();
}
// Average size of landforms
double Landform_size = 0; // Area (number of cells!)
double Lanform_volume = 0; // Volume
Landform_size = (Start_Cells_Wet - Cells_Wet) / Peak_count;
Lanform_volume = (Start_Vol_Wet - Vol_Wet) / Peak_count;
StreamWriter LandformSize;
if (counter == 0)
{
LandformSize = new StreamWriter(filelocation_results + "LandformSize.out");
LandformSize.WriteLine("Counter LandformSize LandformVol PeakCount");
LandformSize.WriteLine(counter + " " + Landform_size + " " + Lanform_volume + " " + Peak_count);
LandformSize.Close();
}
else
{
LandformSize = File.AppendText(filelocation_results + "LandformSize.out");
LandformSize.WriteLine(counter + " " + Landform_size + " " + Lanform_volume + " " + Peak_count);
LandformSize.Close();
}
// Above Average Shoreline position
// Calculate average position of the shoreline, anything above water, seaward of this line is considered a perturbation
int averageY = 0;
double Feature_vol = 0;
double Feature_cells = 0;
for (int ii = 0; ii < TotalBeachCells; ii++)
{
averageY += Y[ii];
}
if (TotalBeachCells > 0)
{
averageY = (averageY / TotalBeachCells) + 1;
}
for (int y_start = averageY; y_start < ymax; y_start++)
{
for (int x_start = 0; x_start < pbEnd; x_start++)
{
if (AboveWater[x_start, y_start] == 1)
{
Feature_vol += Volume[x_start, y_start];
Feature_cells++;
}
}
}
StreamWriter LandformSize_avgShoreline;
if (counter == 0)
{
LandformSize_avgShoreline = new StreamWriter(filelocation_results + "LandformSize_avgShrln.out");
LandformSize_avgShoreline.WriteLine("Counter AverageY TotalLandformSize TotalLandformVol PeakCount Landformsize Landformvol");
LandformSize_avgShoreline.WriteLine(counter + " " + averageY + " " + Feature_cells + " " + Feature_vol + " " + Peak_count + " " + (Feature_vol/Peak_count) + " " + (Feature_cells/Peak_count));
LandformSize_avgShoreline.Close();
}
else
{
LandformSize_avgShoreline = File.AppendText(filelocation_results + "LandformSize_avgShrln.out");
LandformSize_avgShoreline.WriteLine(counter + " " + averageY + " " + Feature_cells + " " + Feature_vol + " " + Peak_count + " " + (Feature_vol / Peak_count) + " " + (Feature_cells / Peak_count));
LandformSize_avgShoreline.Close();
}
}
void PauseRun(int x, int y, int in_)
{
// Pauses run until the 'q' key is pressed
// Can Print or Plot Out Useful info
//MessageBox.Show("Paused");
if (SaveLine == 1)
{
SaveLineToFile();
}
if (SaveFile == 1 || SaveFile == 2)
{
SaveSandToFile();
}
if (NoPauseRun == 1)
{
return;
}
//MessageBox.Show("End Pause");
}
/*.................................................................................................................*/
//Graphics
void drawwater(System.Drawing.Graphics graphics)
{
Graphics objGraphics;
objGraphics = Graphics.FromImage(m_objDrawingSurface);
objGraphics.Clear(SystemColors.Control);
int x, y;
int t = 0;
int redcol = 0, greencol = 0, bluecol = 0;
int alphacol = 255;
double zDEM;
double zCalc; // Value to help identify min, max elevation values
double zMin = 0.0;
double zMax = 10.0;
double zRange;
double hueMin;
double hueMax;
double satMin;
double satMax;
double valMin;
double valMax;
//Elevation
double zElevRange;
//Depth
double zDepthRange;
// Set Graphics Display Size
if (xmax <= 0) xmax = 1;
//set scaling of graphics - so X bmp pixels to every model pixel.
t = graphics_scale;
//// Colour PercentFullSand
//if (menuItemGraphicsSand.Checked == true)
//{
// int b = -1;
// int alpha;
// for (y = ymax - 1; y >= 0; y--)
// {
// b++;
// for (x = 0; x < pbEnd; x++)
// {
// if (PercentFullSand[x, y] > 0.0)
// {
// alpha = 255;
// SolidBrush brush = new SolidBrush(Color.FromArgb(alpha, 255, 0, 0));
// objGraphics.FillRectangle(brush, (x * t), ((b - 1) * t), t, t);
// }
// }
// }
//}
//// Colour Elevation
//if (menuItemGraphicsSand.Checked == true)
//{
// int ex, wy;
// int la = -1;
// int alpha = 255;
// for (wy = ymax - 1; wy >= 0; wy--)
// {
// la++;
// for (ex = 0; ex < pbEnd; ex++)
// {
// if (TElevationDomain[ex, wy] > WaterLevel + maxDomainDepth + WDThreshold)
// //if(AboveWater[ex, wy] > 0)
// {
// SolidBrush brush = new SolidBrush(Color.FromArgb(alpha, 255, 255, 0));
// objGraphics.FillRectangle(brush, (ex * t), ((la - 1) * t), t, t);
// }
// else
// {
// SolidBrush brush = new SolidBrush(Color.FromArgb(alpha, Color.AliceBlue));
// objGraphics.FillRectangle(brush, (ex * t), ((la - 1) * t), t, t);
// }
// }
// }
//}
//int exs, wys;
//int las = -1;
//for (wys = ymax - 1; wys >= 0; wys--)
//{
// las++;
// for (exs = 0; exs < pbEnd; exs++)
// {
// if (DepthShelfMaterial[exs, wys] != DepthShelf[exs, wys] && Elevation[exs, wys] > 0)
// {
// SolidBrush brush = new SolidBrush(Color.Red);
// objGraphics.FillRectangle(brush, (exs * t), ((las - 1) * t), t, t);
// }
// }
//}
// Colour Depth
if (menuItemGraphicDepth.Checked == true)
{
int b = -1;
hueMin = 225.0;
hueMax = 225.0;
satMin = 0.00;
satMax = 0.95;
valMin = 1.00;
valMax = 1.00;
//First find max, mis and range of DEM
if (counter == 0)
{
for (y = ymax - 1; y >= 0; y--)
{
for (x = 0; x < pbEnd; x++)
{
zCalc = (WaterLevel + maxDomainDepth) - TElevationDomain[x, y];
if (zCalc != -9999)
{
if (zCalc < zDepthvMin)
{
zDepthvMin = zCalc;
}
if (zCalc > zDepthMax)
{
zDepthMax = zCalc;
}
}
}
}
}
zDepthRange = zDepthMax - zDepthvMin;
for (y = ymax - 1; y >= 0; y--)
{
b++;
for (x = 0; x < pbEnd; x++)
{
zDEM = (WaterLevel + maxDomainDepth) - TElevationDomain[x, y];
// Hue
hue = hueMax - (((zDEM - zDepthvMin) / (zDepthRange)) * (hueMax - hueMin));
// Saturdation
sat = (((zDEM - zDepthvMin) / (zDepthRange)) * (satMax - satMin)) + satMin;
// Value
val = (((zDEM - zDepthvMin) / (zDepthRange)) * (valMax - valMin)) + valMin;
if (double.IsInfinity(hue))
{
}
Color_HSVtoRGB();
redcol = System.Convert.ToInt32(red * 255);
greencol = System.Convert.ToInt32(green * 255);
bluecol = System.Convert.ToInt32(blue * 255);
alphacol = 50;
if (AboveWater[x, y] == 0)
{
SolidBrush brush = new SolidBrush(Color.FromArgb(alphacol, redcol, greencol, bluecol));
objGraphics.FillRectangle(brush, (x * t), ((b - 1) * t), t, t);
}
}
}
}
// Colour Elevation
if (menuItemGraphicVolume.Checked == true)
{
int b = -1;
////Yellow
//hueMin = 58.0;
//hueMax = 59.0;
//satMin = 0.20;
//satMax = 0.95;
//valMin = 1.00;
//valMax = 1.00;
//Grey
hueMin = 0.00;
hueMax = 0.00;
satMin = 0.00;
satMax = 0.00;
valMin = 0.40;
valMax = 0.50;
//First find max, mis and range of DEM
if (counter == 0)
{
for (y = ymax - 1; y >= 0; y--)
{
for (x = 0; x < pbEnd; x++)
{
zCalc = TElevationDomain[x, y] - (WaterLevel + maxDomainDepth);
if (zCalc != -9999 && zCalc > 0)
{
if (zCalc < zElevMin)
{
zElevMin = zCalc;
}
if (zCalc > zElevMax)
{
zElevMax = zCalc;
}
}
}
}
}
zElevRange = zElevMax - zElevMin;
for (y = ymax - 1; y >= 0; y--)
{
b++;
for (x = 0; x < pbEnd; x++)
{
zDEM = TElevationDomain[x, y] - (WaterLevel + maxDomainDepth);
// Hue
hue = hueMax - (((zDEM - zElevMin) / (zElevRange)) * (hueMax - hueMin));
if (double.IsInfinity(hue))
{
}
// Saturdation
sat = (((zDEM - zElevMin) / (zElevRange)) * (satMax - satMin)) + satMin;
// Value
val = (((zDEM - zElevMin) / (zElevRange)) * (valMax - valMin)) + valMin;
Color_HSVtoRGB();
redcol = System.Convert.ToInt32(red * 255);
greencol = System.Convert.ToInt32(green * 255);
bluecol = System.Convert.ToInt32(blue * 255);
alphacol = 100;
//if (zDEM == 0.0)
//{
// SolidBrush brush = new SolidBrush(Color.FromArgb(50,Color.AliceBlue));
// objGraphics.FillRectangle(brush, (x * t), ((b - 1) * t), t, t);
//}
if (AboveWater[x, y] == 1)
{
//SolidBrush brush = new SolidBrush(Color.FromArgb(alphacol, redcol, greencol, bluecol));
SolidBrush brush = new SolidBrush(Color.Gray);
objGraphics.FillRectangle(brush, (x * t), ((b - 1) * t), t, t);
}
//else
//{
// SolidBrush brush = new SolidBrush(Color.FromArgb(50, Color.AliceBlue));
// objGraphics.FillRectangle(brush, (x * t), ((b - 1) * t), t, t);
//}
}
}
}
////// Colour PercentFullRock
////if (menuItemGraphicsRock.Checked == true)
////{
//// int a = -1;
//// for (y = ymax - 1; y >= 0; y--)
//// {
//// a++;
//// for (x = 0; x < pbEnd; x++)
//// {
//// if (PercentFullRock[x, y] > 0.0)
//// {
//// SolidBrush brush = new SolidBrush(Color.SaddleBrown);
//// objGraphics.FillRectangle(brush, (x * t), ((a - 1) * t), t, t);
//// }
//// }
//// }
////}
////// Colour AboveTideOLD = FALSE
////int c = -1;
////for (y = ymax - 1; y >= 0; y--)
////{
//// c++;
//// //for (x = xDisplayStart; x < xDisplayEnd; x++)
//// for (x = 0; x < pbEnd; x++)
//// {
//// // PercentFull Sand
//// if (AboveTideOLD[x, y] == false)
//// {
//// SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(50, 100, 149, 237));
//// //SolidBrush semiTransBrush = new SolidBrush(Color.Turquoise);
//// objGraphics.FillRectangle(semiTransBrush, ((x /*- xDisplayStart*/) * t), ((c - 1) * t), t, t);
//// }
//// }
////}
// Colour the X[] Y[] array (beach/tide mark)
if (menuItemGraphicsXY.Checked == true)
{
int d = 0;
int e = 0;
int f;
int g;
while (X[d] > -1 && Y[d] > -1 && d < (X.Length - 1))
{
f = X[d];
g = Y[e];
SolidBrush brush = new SolidBrush(Color.Blue);
objGraphics.FillRectangle(brush, (f * t), (((ymax - 2) - g) * t), t, t);
//if (InShadow[d] == 'y')
//{
// SolidBrush brush_red = new SolidBrush(Color.Red);
// objGraphics.FillRectangle(brush_red, (f * t), (((ymax - 2) - g) * t), t, t);
//}
d++;
e++;
}
}
// Initial XY
if (menuItemGraphicInitialXY.Checked == true)
{
int d = 0;
int e = 0;
int f;
int g;
while (initialX[d] > -1 && initialY[d] > -1 && d < (initialX.Length - 1))
{
f = initialX[d];
g = initialY[e];
SolidBrush brush = new SolidBrush(Color.DarkBlue);
objGraphics.FillRectangle(brush, (f * t), (((ymax - 2) - g) * t), t, t);
d++;
e++;
}
}
// Shadow
if (menuItemShadow.Checked == true)
{
this.waveAnglePanel.Text = Convert.ToString(WaveAngle * radtodeg);
int bb = -1;
for (int yy = ymax - 1; yy >= 0; yy--)
{
bb++;
for (int xx = 0; xx < pbEnd; xx++)
{
if (InShadow_domain[xx, yy] == 1 && AboveWater[xx, yy] == 0)
{
SolidBrush brush = new SolidBrush(Color.Orange);
objGraphics.FillRectangle(brush, (xx * t), ((bb - 1) * t), t, t);
}
}
}
}
// RED / GREEN for +- material > 2m
if (menuItemGraphicsRock.Checked == true)
{
int bb = -1;
for (int yy = ymax - 1; yy >= 0; yy--)
{
bb++;
for (int xx = 0; xx < pbEnd; xx++)
{
//if (((PreviousVolume[xx, yy] - Volume[xx, yy]) / (CellWidth * CellWidth)) < -0)
//{
// SolidBrush brush = new SolidBrush(Color.Green);
// objGraphics.FillRectangle(brush, (xx * t), ((bb - 1) * t), t, t);
// //// Qw Status panel
// //this.QwStatusPanel.Text = xx + "," + yy + " : " + ((PreviousVolume[xx, yy] - Volume[xx, yy]) / (CellWidth * CellWidth));
//}
//else if (((PreviousVolume[xx, yy] - Volume[xx, yy]) / (CellWidth * CellWidth)) > 0)
//{
// SolidBrush brush = new SolidBrush(Color.Red);
// objGraphics.FillRectangle(brush, (xx * t), ((bb - 1) * t), t, t);
// //// Qs Status panel
// //this.QsStatusPanel.Text = xx + "," + yy + " : " + ((PreviousVolume[xx, yy] - Volume[xx, yy]) / (CellWidth * CellWidth));
//}
if (Linear_Shoreline[xx, yy] == 1)
{
SolidBrush brush = new SolidBrush(Color.Green);
objGraphics.FillRectangle(brush, (xx * t), ((bb - 1) * t), t, t);
}
//else if (AboveWater[xx, yy] == 1)
//{
// SolidBrush brush = new SolidBrush(Color.LightGray);
// objGraphics.FillRectangle(brush, (xx * t), ((bb - 1) * t), t, t);
//}
//if ((((PreviousVolume[xx, yy] - Volume[xx, yy]) / (CellWidth * CellWidth)) < -0) && AboveWater[xx, yy] == 1)
//{
// SolidBrush brush = new SolidBrush(Color.Green);
// objGraphics.FillRectangle(brush, (xx * t), ((bb - 1) * t), t, t);
// // Qw Status panel
// this.QwStatusPanel.Text = xx + "," + yy + " : " + ((PreviousVolume[xx, yy] - Volume[xx, yy]) / (CellWidth * CellWidth));
//}
//else if ((((PreviousVolume[xx, yy] - Volume[xx, yy]) / (CellWidth * CellWidth)) > 0) && AboveWater[xx, yy] == 1)
//{
// SolidBrush brush = new SolidBrush(Color.Red);
// objGraphics.FillRectangle(brush, (xx * t), ((bb - 1) * t), t, t);
// // Qs Status panel
// this.QsStatusPanel.Text = xx + "," + yy + " : " + ((PreviousVolume[xx, yy] - Volume[xx, yy]) / (CellWidth * CellWidth));
//}
//else
//{
// SolidBrush brush = new SolidBrush(Color.LightGray);
// objGraphics.FillRectangle(brush, (xx * t), ((bb - 1) * t), t, t);
//}
}
}
}
string drawString1 = "0";
string drawString2 = Convert.ToString(xDisplayStart);
string drawString3 = Convert.ToString(xmax);
string drawString4 = Convert.ToString(xDisplayEnd);
string drawString5 = Convert.ToString(pbEnd);
string drawString6 = Convert.ToString(ymax/2);
string drawString7 = Convert.ToString(ymax);
Font drawFont = new Font("Arial", 5);
SolidBrush TextBrush = new SolidBrush(Color.Black);
objGraphics.DrawString(drawString1, drawFont, TextBrush, (0 * t), ((ymax-2) * t));
objGraphics.DrawString(drawString2, drawFont, TextBrush, (xDisplayStart * t), ((ymax - 2) * t));
objGraphics.DrawString(drawString3, drawFont, TextBrush, (xmax * t), ((ymax - 2) * t));
objGraphics.DrawString(drawString4, drawFont, TextBrush, (xDisplayEnd * t), ((ymax - 2) * t));
objGraphics.DrawString(drawString5, drawFont, TextBrush, ((pbEnd-(drawString5.Length)) * t), ((ymax - 2) * t));
objGraphics.DrawString(drawString6, drawFont, TextBrush, (0 * t), ((ymax / 2) * t));
objGraphics.DrawString(drawString7, drawFont, TextBrush, (0 * t), ((0) * t));
drawFont.Dispose();
TextBrush.Dispose();
objGraphics.Dispose();
zoomPanImageBox1.Image = m_objDrawingSurface;
}
void Color_HSVtoRGB()
{
// Convert HSV to RGB.
if (sat == 0)
{
// If sat is 0, all colors are the same - this is some flavor of gray.
red = val;
green = val;
blue = val;
}
else
{
double pFactor;
double qFactor;
double tFactor;
double fractionalSector;
int sectorNumber;
double sectorPos;
// The color wheel consists of six 60 degree sectors
// Figure out which sector you are in.
sectorPos = hue / 60;
sectorNumber = (int)(Math.Floor(sectorPos));
// get the fractional part of the sector.
// That is, how many degrees into the sector are you?
fractionalSector = sectorPos - sectorNumber;
// Calculate values for the three axes of the color.
pFactor = val * (1 - sat);
qFactor = val * (1 - (sat * fractionalSector));
tFactor = val * (1 - (sat * (1 - fractionalSector)));
// Assign the fractional colors to r, g, and b based on the sector the angle is in.
switch (sectorNumber)
{
case 0:
red = val;
green = tFactor;
blue = pFactor;
break;
case 1:
red = qFactor;
green = val;
blue = pFactor;
break;
case 2:
red = pFactor;
green = val;
blue = tFactor;
break;
case 3:
red = pFactor;
green = qFactor;
blue = val;
break;
case 4:
red = tFactor;
green = pFactor;
blue = val;
break;
case 5:
red = val;
green = pFactor;
blue = qFactor;
break;
}
}
}
private void Form1_Resize(object sender, EventArgs e)
{
zoomPanImageBox1.Height = this.Height - 225;
zoomPanImageBox1.Width = this.Width - 20;
}
private void zoomPanImageBox1_Load(object sender, EventArgs e)
{
}
private void statusBar1_PanelClick(object sender, System.Windows.Forms.StatusBarPanelClickEventArgs e)
{
// No action
}
//File Tab
private void menuItemFileOpen_Click(object sender, System.EventArgs e)
{
XmlTextReader xreader;
OpenFileDialog ConfigOpen = new OpenFileDialog();
ConfigOpen.InitialDirectory = Directory.GetCurrentDirectory();
ConfigOpen.Filter = "cfg files (*.xml)|*.xml|All files (*.*)|*.*";
ConfigOpen.FilterIndex = 1;
ConfigOpen.RestoreDirectory = false;
if (ConfigOpen.ShowDialog() == DialogResult.OK)
{
ConfigName = ConfigOpen.FileName;
xreader = new XmlTextReader(ConfigName);
//Read the file
if (xreader != null)
{
xreader.ReadStartElement("Parameters");
// DEM
xreader.ReadStartElement("DigitalElevationModel");
DEMTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("DEMTick"));
DEMTextBox.Text = xreader.ReadElementString("DEMTextBox");
CompDEMTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("CompDEMTick"));
NormTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("NormTick"));
WigglyTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("WigglyTick"));
BlockTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("BlockTick"));
ColumnTB.Text = xreader.ReadElementString("ColumnTB");
RowsTB.Text = xreader.ReadElementString("RowsTB");
xreader.ReadEndElement();
// Wave Climate
xreader.ReadStartElement("WaveClimate");
ManWavTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("ManWavTick"));
WaveFileTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("WaveFileTick"));
BinnedTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("BinnedTick"));
WAngleTB.Text = xreader.ReadElementString("WAngleTB");
WPeriodTB.Text = xreader.ReadElementString("WPeriodTB");
WHeightTB.Text = xreader.ReadElementString("WHeightTB");
WaveFileTB.Text = xreader.ReadElementString("WaveFileTB");
WALoadTB.Text = xreader.ReadElementString("WALoadTB");
WPLoadTB.Text = xreader.ReadElementString("WPLoadTB");
WHLoadTB.Text = xreader.ReadElementString("WHLoadTB");
xreader.ReadEndElement();
// Tides
xreader.ReadStartElement("Tides");
DoTidesTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("DoTidesTick"));
LowTideTB.Text = xreader.ReadElementString("WaterHeightTB");
HighTideTB.Text = xreader.ReadElementString("HighTideTB");
xreader.ReadEndElement();
// Erosion and Weathering
xreader.ReadStartElement("ErosionWeathering");
ErosRateTB.Text = xreader.ReadElementString("ErosRateTB");
PercentFastTB.Text = xreader.ReadElementString("PercentFastTB");
PercentSlowTB.Text = xreader.ReadElementString("PercentSlowTB");
RockWeatherTB.Text = xreader.ReadElementString("RockWeatherTB");
SlowWeatherTB.Text = xreader.ReadElementString("SlowWeatherTB");
FastWeatherTB.Text = xreader.ReadElementString("FastWeatherTB");
xreader.ReadEndElement();
// Sources and Sinks
xreader.ReadStartElement("SourcesSinks");
SourceTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("SourceTick"));
ColSourceTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("ColSourceTick"));
NumSourceTB.Text = xreader.ReadElementString("NumSourceTB");
XSourceTB.Text = xreader.ReadElementString("XSourceTB");
YSourceTB.Text = xreader.ReadElementString("YSourceTB");
SinkTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("SinkTick"));
ColSinkTick.Checked = XmlConvert.ToBoolean(xreader.ReadElementString("ColSinkTick"));
NumSinkTB.Text = xreader.ReadElementString("NumSinkTB");
SinkinessTB.Text = xreader.ReadElementString("SinkinessTB");
XSinkTB.Text = xreader.ReadElementString("XSinkTB");
YSinkTB.Text = xreader.ReadElementString("YSinkTB");
xreader.ReadEndElement();
// Outputs
xreader.ReadStartElement("OutputsTab");
OutputNameTB.Text = xreader.ReadElementString("OutputNameTB");
SaveFreqTB.Text = xreader.ReadElementString("SaveFreqTB");
RunLengthTB.Text = xreader.ReadElementString("RunLengthTB");
xreader.ReadEndElement();
// Description
xreader.ReadStartElement("DescripTB");
DescripTB.Text = xreader.ReadElementString("DescripTB");
xreader.ReadEndElement();
xreader.Close();
this.Text = basetext + " (" + Path.GetFileName(ConfigName) + ")";
loadDataButton.Enabled = true;
startButton.Enabled = false;
}
}
}
private void menuItemFileSave_Click(object sender, System.EventArgs e)
{
XmlTextWriter xwriter;
if ((sender == menuItemFileSaveAs) || (ConfigName == null))
{
SaveFileDialog saveAsConfig = new SaveFileDialog();
saveAsConfig.InitialDirectory = Directory.GetCurrentDirectory();
saveAsConfig.Filter = "cfg files (*.xml)|*.xml|All files (*.*)|*.*";
saveAsConfig.FilterIndex = 1;
saveAsConfig.RestoreDirectory = false;
if (saveAsConfig.ShowDialog() == DialogResult.OK)
{
ConfigName = saveAsConfig.FileName;
}
}
if (ConfigName != null)
{
//Create a new XmlTextWriter.
xwriter = new XmlTextWriter(ConfigName, System.Text.Encoding.UTF8);
//Write the beginning of the document including the document declaration. Standalone is true.
//Use indentation for readability.
xwriter.Formatting = Formatting.Indented;
xwriter.Indentation = 4;
xwriter.WriteStartDocument(true);
//Write the beginning of the "data" element. This is the opening tag to our data
xwriter.WriteStartElement("Parameters");
// DEM
xwriter.WriteStartElement("DigitalElevationModel");
xwriter.WriteElementString("DEMTick", XmlConvert.ToString(DEMTick.Checked));
xwriter.WriteElementString("DEMTextBox", DEMTextBox.Text);
xwriter.WriteElementString("CompDEMTick", XmlConvert.ToString(CompDEMTick.Checked));
xwriter.WriteElementString("NormTick", XmlConvert.ToString(NormTick.Checked));
xwriter.WriteElementString("WigglyTick", XmlConvert.ToString(WigglyTick.Checked));
xwriter.WriteElementString("BlockTick", XmlConvert.ToString(BlockTick.Checked));
xwriter.WriteElementString("ColumnTB", ColumnTB.Text);
xwriter.WriteElementString("RowsTB", RowsTB.Text);
xwriter.WriteEndElement();
// Wave Climate
xwriter.WriteStartElement("WaveClimate");
xwriter.WriteElementString("ManWavTick", XmlConvert.ToString(ManWavTick.Checked));
xwriter.WriteElementString("WaveFileTick", XmlConvert.ToString(WaveFileTick.Checked));
xwriter.WriteElementString("BinnedTick", XmlConvert.ToString(BinnedTick.Checked));
xwriter.WriteElementString("WAngleTB", WAngleTB.Text);
xwriter.WriteElementString("WPeriodTB", WPeriodTB.Text);
xwriter.WriteElementString("WHeightTB", WHeightTB.Text);
xwriter.WriteElementString("WaveFileTB", WaveFileTB.Text);
xwriter.WriteElementString("WALoadTB", WALoadTB.Text);
xwriter.WriteElementString("WPLoadTB", WPLoadTB.Text);
xwriter.WriteElementString("WHLoadTB", WHLoadTB.Text);
xwriter.WriteEndElement();
// Tides
xwriter.WriteStartElement("Tides");
xwriter.WriteElementString("DoTidesTick", XmlConvert.ToString(DoTidesTick.Checked));
xwriter.WriteElementString("WaterHeightTB", LowTideTB.Text);
xwriter.WriteElementString("HighTideTB", HighTideTB.Text);
xwriter.WriteEndElement();
// Erosion and Weathering
xwriter.WriteStartElement("ErosionWeathering");
xwriter.WriteElementString("ErosRateTB", ErosRateTB.Text);
xwriter.WriteElementString("PercentFastTB", PercentFastTB.Text);
xwriter.WriteElementString("PercentSlowTB", PercentSlowTB.Text);
xwriter.WriteElementString("RockWeatherTB", RockWeatherTB.Text);
xwriter.WriteElementString("SlowWeatherTB", SlowWeatherTB.Text);
xwriter.WriteElementString("FastWeatherTB", FastWeatherTB.Text);
xwriter.WriteEndElement();
// Sources and Sinks
xwriter.WriteStartElement("SourcesSinks");
xwriter.WriteElementString("SourceTick", XmlConvert.ToString(SourceTick.Checked));
xwriter.WriteElementString("ColSourceTick", XmlConvert.ToString(ColSourceTick.Checked));
xwriter.WriteElementString("NumSourceTB", NumSourceTB.Text);
xwriter.WriteElementString("XSourceTB", XSourceTB.Text);
xwriter.WriteElementString("YSourceTB", YSourceTB.Text);
xwriter.WriteElementString("SinkTick", XmlConvert.ToString(SinkTick.Checked));
xwriter.WriteElementString("ColSinkTick", XmlConvert.ToString(ColSinkTick.Checked));
xwriter.WriteElementString("NumSinkTB", NumSinkTB.Text);
xwriter.WriteElementString("SinkinessTB", SinkinessTB.Text);
xwriter.WriteElementString("XSinkTB", XSinkTB.Text);
xwriter.WriteElementString("YSinkTB", YSinkTB.Text);
xwriter.WriteEndElement();
// Outputs
xwriter.WriteStartElement("OutputsTab");
xwriter.WriteElementString("OutputNameTB", OutputNameTB.Text);
xwriter.WriteElementString("SaveFreqTB", SaveFreqTB.Text);
xwriter.WriteElementString("RunLengthTB", RunLengthTB.Text);
xwriter.WriteEndElement();
// Description
xwriter.WriteStartElement("DescripTB");
xwriter.WriteElementString("DescripTB", DescripTB.Text);
xwriter.WriteEndElement();
xwriter.WriteEndElement();
//End the document
xwriter.WriteEndDocument();
//Flush the xml document to the underlying stream and
//close the underlying stream. The data will not be
//written out to the stream until either the Flush()
//method is called or the Close() method is called.
xwriter.Close();
this.Text = basetext + " (" + Path.GetFileName(ConfigName) + ")";
}
}
// Graphics Tab
private void menuItemGraphicsRock_Click(object sender, EventArgs e)
{
if (menuItemGraphicsRock.Checked == true)
{
menuItemGraphicsRock.Checked = false;
}
else if (menuItemGraphicsRock.Checked == false)
{
menuItemGraphicsRock.Checked = true;
}
updateClick = 1;
this.Refresh();
drawwater(mygraphics);
}
private void menuItemGraphicsSand_Click(object sender, EventArgs e)
{
if (menuItemGraphicsSand.Checked == true)
{
menuItemGraphicsSand.Checked = false;
}
else if (menuItemGraphicsSand.Checked == false)
{
menuItemGraphicsSand.Checked = true;
}
updateClick = 1;
this.Refresh();
drawwater(mygraphics);
}
private void menuItemGraphicsXY_Click(object sender, EventArgs e)
{
if (menuItemGraphicsXY.Checked == true)
{
menuItemGraphicsXY.Checked = false;
}
else if (menuItemGraphicsXY.Checked == false)
{
menuItemGraphicsXY.Checked = true;
}
updateClick = 1;
this.Refresh();
drawwater(mygraphics);
}
private void menuItemGraphicDepth_Click(object sender, EventArgs e)
{
if (menuItemGraphicDepth.Checked == true)
{
menuItemGraphicDepth.Checked = false;
}
else if (menuItemGraphicDepth.Checked == false)
{
menuItemGraphicDepth.Checked = true;
}
updateClick = 1;
this.Refresh();
drawwater(mygraphics);
}
private void menuItemGraphicVolume_Click(object sender, EventArgs e)
{
if (menuItemGraphicVolume.Checked == true)
{
menuItemGraphicVolume.Checked = false;
}
else if (menuItemGraphicVolume.Checked == false)
{
menuItemGraphicVolume.Checked = true;
}
updateClick = 1;
this.Refresh();
drawwater(mygraphics);
}
private void menuItemGraphicInitialXY_Click(object sender, EventArgs e)
{
if (menuItemGraphicInitialXY.Checked == true)
{
menuItemGraphicInitialXY.Checked = false;
}
else if (menuItemGraphicInitialXY.Checked == false)
{
menuItemGraphicInitialXY.Checked = true;
}
updateClick = 1;
this.Refresh();
drawwater(mygraphics);
}
private void menuItemShadow_Click(object sender, EventArgs e)
{
if (menuItemShadow.Checked == true)
{
menuItemShadow.Checked = false;
}
else if (menuItemShadow.Checked == false)
{
menuItemShadow.Checked = true;
}
updateClick = 1;
this.Refresh();
drawwater(mygraphics);
}
// Scroll Bars
private void trackBar1_Scroll(object sender, EventArgs e)
{
contrastMultiplier = contrastFactor[trackBar1.Value];
drawwater(mygraphics);
}
private void trackBar2_Scroll(object sender, EventArgs e)
{
magnifyValue = zoomFactor[this.trackBar2.Value];
zoomPanImageBox1.setZoom();
}
private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
{
updateClick = 1;
this.Refresh();
drawwater(mygraphics);
}
// Quick Buttons
private void updateGraphics_Click_1(object sender, System.EventArgs e)
{
updateClick = 1;
this.Refresh();
drawwater(mygraphics);
}
void quitSaveButton_Click(object sender, System.EventArgs e)
{
save_data(1,9999);
this.Close();
}
private void resumeButton_Click(object sender, EventArgs e)
{
gameClock.Start();
}
private void pauseButton_Click(object sender, EventArgs e)
{
this.updateGraphics_Click_1(updateGraphicsButton, EventArgs.Empty);
this.QwStatusPanel.Text = Convert.ToString(WaveAngle);
this.QsStatusPanel.Text = Convert.ToString(WaveAngle * (180.0 / Math.PI));
gameClock.Stop();
}
private void SeeTabsButton_Click(object sender, EventArgs e)
{
if (this.MainWindowTabs.Visible == true)
{
MainWindowTabs.Visible = false;
SeeTabsButton.Text = "See Tabs";
}
else if (this.MainWindowTabs.Visible == false)
{
MainWindowTabs.Visible = true;
SeeTabsButton.Text = "Simulation";
}
}
// DEM
private void DEMFileExplorer_Click(object sender, EventArgs e)
{
string[] DEMLineArray = new string[3];
string[] DEMLineArray2 = new string[2];
int z;
int xFromFile;
int yFromFile;
OpenFileDialog DEMFileName = new OpenFileDialog();
DEMFileName.InitialDirectory = Directory.GetCurrentDirectory();
if (DEMFileName.ShowDialog() == DialogResult.OK)
{
DEMFilePath = DEMFileName.FileName;
DEMTextBox.Text = DEMFileName.SafeFileName;
Stream fileStream = DEMFileName.OpenFile();
StreamReader reader = new StreamReader(fileStream);
for (z = 1; z <= 3; z++)
{
DEMLineArray[z - 1] = reader.ReadLine();
}
// get xmax and ymax from input headers
DEMLineArray2 = DEMLineArray[0].Split(new char[] { ' ' }); // Number of Columns
int sp = 1;
while (DEMLineArray[sp] == "")
{
sp++;
}
xFromFile = int.Parse(DEMLineArray2[sp]);
DEMLineArray2 = DEMLineArray[1].Split(new char[] { ' ' }); // Number of Rows
sp = 1;
while (DEMLineArray2[sp] == "")
{
sp++;
}
yFromFile = (int.Parse(DEMLineArray2[sp]) / 3);
ColumnTB.Text = Convert.ToString(xFromFile);
RowsTB.Text = Convert.ToString(yFromFile);
fileStream.Close();
}
}
private void DEMTick_CheckedChanged(object sender, EventArgs e)
{
if (DEMTick.Checked == true)
{
DEMTextBox.Enabled = true;
DEMTextBox.ForeColor = Color.Black;
DEMBrowseButton.Enabled = true;
DEMBrowseButton.ForeColor = Color.Black;
CompDEMTick.Checked = false;
ColumnTB.ReadOnly = true;
RowsTB.ReadOnly = true;
ColLabel.ForeColor = Color.Black;
RowLabel.ForeColor = Color.Black;
if (string.IsNullOrWhiteSpace(this.DEMTextBox.Text))
{
ColumnTB.Text = "";
RowsTB.Text = "";
}
else
{
//Find x and y values for DEM in textbox
string[] DEMLineArray = new string[3];
string[] DEMLineArray2 = new string[2];
int z;
StreamReader reader = new StreamReader("INPUT_FILES/" + DEMTextBox.Text);
for (z = 1; z <= 3; z++)
{
DEMLineArray[z - 1] = reader.ReadLine();
}
// get xmax and ymax from input headers
DEMLineArray2 = DEMLineArray[0].Split(new char[] { ' ' }); // Number of Columns
int sp = 1;
while (DEMLineArray[sp] == "")
{
sp++;
}
xmax = int.Parse(DEMLineArray2[sp]);
DEMLineArray2 = DEMLineArray[1].Split(new char[] { ' ' }); // Number of Rows
sp = 1;
while (DEMLineArray2[sp] == "")
{
sp++;
}
ymax = (int.Parse(DEMLineArray2[sp]) / 3);
ColumnTB.Text = Convert.ToString(xmax);
RowsTB.Text = Convert.ToString(ymax);
}
}
else if (DEMTick.Checked == false)
{
DEMTextBox.Enabled = false;
DEMTextBox.ForeColor = Color.Gray;
DEMBrowseButton.Enabled = false;
DEMBrowseButton.ForeColor = Color.Gray;
ColumnTB.Enabled = false;
RowsTB.Enabled = false;
ColumnTB.ReadOnly = true;
RowsTB.ReadOnly = true;
ColLabel.ForeColor = Color.Gray;
RowLabel.ForeColor = Color.Gray;
ColumnTB.Text = "";
RowsTB.Text = "";
DEMTextBox.Text = "";
}
}
private void CompDEMTick_CheckedChanged(object sender, EventArgs e)
{
if (CompDEMTick.Checked == true)
{
NormLabel.ForeColor = Color.Black;
NormTick.Enabled = true;
WigglyLabel.ForeColor = Color.Black;
WigglyTick.Enabled = true;
BlockLabel.ForeColor = Color.Black;
BlockTick.Enabled = true;
InitPertLab.ForeColor = Color.Black;
InitPertTick.Enabled = true;
PertLab.ForeColor = Color.Black;
PertTick.Enabled = true;
DEMTick.Checked = false;
ColumnTB.Enabled = true;
RowsTB.Enabled = true;
ColumnTB.ReadOnly = false;
RowsTB.ReadOnly = false;
ColLabel.ForeColor = Color.Black;
RowLabel.ForeColor = Color.Black;
ColLabel.Font = new Font(ColLabel.Font, FontStyle.Bold);
RowLabel.Font = new Font(RowLabel.Font, FontStyle.Bold);
}
else if (CompDEMTick.Checked == false)
{
NormLabel.ForeColor = Color.Gray;
NormTick.Enabled = false;
NormTick.Checked = false;
WigglyLabel.ForeColor = Color.Gray;
WigglyTick.Enabled = false;
WigglyTick.Checked = false;
BlockLabel.ForeColor = Color.Gray;
BlockTick.Enabled = false;
BlockTick.Checked = false;
InitPertLab.ForeColor = Color.Gray;
InitPertTick.Enabled = false;
InitPertTick.Checked = false;
PertLab.ForeColor = Color.Gray;
PertTick.Enabled = false;
PertTick.Checked = false;
ColumnTB.Enabled = false;
RowsTB.Enabled = false;
ColumnTB.ReadOnly = true;
RowsTB.ReadOnly = true;
ColLabel.ForeColor = Color.Gray;
RowLabel.ForeColor = Color.Gray;
ColLabel.Font = new Font(ColLabel.Font, FontStyle.Regular);
RowLabel.Font = new Font(RowLabel.Font, FontStyle.Regular);
ColumnTB.Text = "";
RowsTB.Text = "";
}
}
private void NormTick_CheckedChanged(object sender, EventArgs e)
{
if (NormTick.Checked == true)
{
WigglyTick.Checked = false;
BlockTick.Checked = false;
InitPertTick.Checked = false;
PertTick.Checked = false;
}
}
private void WigglyTick_CheckedChanged(object sender, EventArgs e)
{
if (WigglyTick.Checked == true)
{
NormTick.Checked = false;
BlockTick.Checked = false;
InitPertTick.Checked = false;
PertTick.Checked = false;
}
}
private void BlockTick_CheckedChanged(object sender, EventArgs e)
{
if (BlockTick.Checked == true)
{
NormTick.Checked = false;
WigglyTick.Checked = false;
InitPertTick.Checked = false;
PertTick.Checked = false;
}
}
private void InitPertTick_CheckedChanged(object sender, EventArgs e)
{
if (InitPertTick.Checked == true)
{
NormTick.Checked = false;
WigglyTick.Checked = false;
BlockTick.Checked = false;
PertTick.Checked = false;
}
}
private void PertTick_CheckedChanged(object sender, EventArgs e)
{
if (PertTick.Checked == true)
{
NormTick.Checked = false;
WigglyTick.Checked = false;
BlockTick.Checked = false;
InitPertTick.Checked = false;
}
}
// Waves
private void WaveBrowseButton_Click(object sender, EventArgs e)
{
OpenFileDialog WaveFileName = new OpenFileDialog();
WaveFileName.InitialDirectory = Directory.GetCurrentDirectory();
if (WaveFileName.ShowDialog() == DialogResult.OK)
{
WaveFileTB.Text = WaveFileName.SafeFileName;
Stream fileStream = WaveFileName.OpenFile();
StreamReader reader = new StreamReader(fileStream);
// Get 1st Wave Angle, Period, Height in file
realWave_Content = reader.ReadLine();
realWave_Content = realWave_Content.Replace("\r\n", " ");
realWave_Content = realWave_Content.Replace("\t", " ");
realWave_Content = Regex.Replace(realWave_Content, @"\s+", " ");
realWave_Content = realWave_Content.Trim();
realWave_Split = realWave_Content.Split(' ');
fileStream.Close();
WaveAngleIn = Convert.ToDouble(realWave_Split[0]);
WavePeriodIn = Convert.ToDouble(realWave_Split[1]);
WaveHeightIn = Convert.ToDouble(realWave_Split[2]);
WALoadTB.Text = Convert.ToString(WaveAngleIn);
WPLoadTB.Text = Convert.ToString(WavePeriodIn);
WHLoadTB.Text = Convert.ToString(WaveHeightIn);
}
}
private void WaveFileTick_CheckedChanged(object sender, EventArgs e)
{
if (WaveFileTick.Checked == true)
{
WaveBrowseButton.Enabled = true;
WaveFileTB.Enabled = true;
WaveFileTB.ReadOnly = false;
WaveBrowseButton.ForeColor = Color.Black;
WaveFileLabel.ForeColor = Color.Black;
WALoadLab.ForeColor = Color.Black;
WHLoadLab.ForeColor = Color.Black;
WPLoadLab.ForeColor = Color.Black;
ManWavTick.Checked = false;
ManWavLabel.ForeColor = Color.Gray;
WAngleLabel.ForeColor = Color.Gray;
WPeriodLabel.ForeColor = Color.Gray;
WHeightLabel.ForeColor = Color.Gray;
WAngleTB.Text = "";
WPeriodTB.Text = "";
WHeightTB.Text = "";
WAngleTB.Enabled = false;
WPeriodTB.Enabled = false;
WHeightTB.Enabled = false;
WAngleTB.ReadOnly = true;
WPeriodTB.ReadOnly = true;
WHeightTB.ReadOnly = true;
UA_WaveTick.Checked = false;
UALab.ForeColor = Color.Gray;
AsymLab.ForeColor = Color.Gray;
HighLab.ForeColor = Color.Gray;
AsymTB.Text = "";
HighTB.Text = "";
AsymTB.Enabled = false;
HighTB.Enabled = false;
AsymTB.ReadOnly = true;
HighTB.ReadOnly = true;
// CM - not using this for now
//BinnedLabel.ForeColor = Color.Black;
//BinnedTick.Enabled = true;
}
else if (WaveFileTick.Checked == false)
{
WaveBrowseButton.Enabled = false;
WaveFileTB.Enabled = false;
WaveFileTB.ReadOnly = true;
WaveFileTB.Text = "";
WaveBrowseButton.ForeColor = Color.Gray;
WaveFileLabel.ForeColor = Color.Gray;
WALoadLab.ForeColor = Color.Gray;
WHLoadLab.ForeColor = Color.Gray;
WPLoadLab.ForeColor = Color.Gray;
WALoadTB.Text = "";
WHLoadTB.Text = "";
WPLoadTB.Text = "";
//CM - not using this for now
//BinnedLabel.ForeColor = Color.Gray;
//BinnedTick.Enabled = false;
}
}
private void ManWavTick_CheckedChanged(object sender, EventArgs e)
{
if (ManWavTick.Checked == true)
{
ManWavLabel.ForeColor = Color.Black;
WHeightLabel.ForeColor = Color.Black;
WPeriodLabel.ForeColor = Color.Black;
WAngleLabel.ForeColor = Color.Black;
WHeightTB.Enabled = true;
WPeriodTB.Enabled = true;
WAngleTB.Enabled = true;
WAngleTB.ReadOnly = false;
WPeriodTB.ReadOnly = false;
WHeightTB.ReadOnly = false;
WaveFileTick.Checked = false;
WaveBrowseButton.Enabled = false;
WaveFileTB.Enabled = false;
WaveFileTB.ReadOnly = true;
WaveBrowseButton.ForeColor = Color.Gray;
WaveFileLabel.ForeColor = Color.Gray;
WALoadLab.ForeColor = Color.Gray;
WHLoadLab.ForeColor = Color.Gray;
WPLoadLab.ForeColor = Color.Gray;
UA_WaveTick.Checked = false;
UALab.ForeColor = Color.Gray;
AsymLab.ForeColor = Color.Gray;
HighLab.ForeColor = Color.Gray;
AsymTB.Text = "";
HighTB.Text = "";
AsymTB.Enabled = false;
HighTB.Enabled = false;
AsymTB.ReadOnly = true;
HighTB.ReadOnly = true;
//BinnedTick.Checked = false;
}
else if (ManWavTick.Checked == false)
{
ManWavLabel.ForeColor = Color.Gray;
WHeightLabel.ForeColor = Color.Gray;
WPeriodLabel.ForeColor = Color.Gray;
WAngleLabel.ForeColor = Color.Gray;
WHeightTB.Enabled = false;
WPeriodTB.Enabled = false;
WAngleTB.Enabled = false;
WHeightTB.Text = "";
WPeriodTB.Text = "";
WAngleTB.Text = "";
}
}
private void UA_WaveTickTick_CheckedChanged(object sender, EventArgs e)
{
if (UA_WaveTick.Checked == true)
{
UA_WaveTick.Checked = true;
UALab.ForeColor = Color.Black;
AsymLab.ForeColor = Color.Black;
HighLab.ForeColor = Color.Black;
AsymTB.Enabled = true;
HighTB.Enabled = true;
AsymTB.ReadOnly = false;
HighTB.ReadOnly = false;
WaveFileTick.Checked = false;
WaveBrowseButton.Enabled = false;
WaveFileTB.Enabled = false;
WaveFileTB.ReadOnly = true;
WaveBrowseButton.ForeColor = Color.Gray;
WaveFileLabel.ForeColor = Color.Gray;
WALoadLab.ForeColor = Color.Gray;
WHLoadLab.ForeColor = Color.Gray;
WPLoadLab.ForeColor = Color.Gray;
ManWavTick.Checked = false;
WHeightLabel.ForeColor = Color.Gray;
WPeriodLabel.ForeColor = Color.Gray;
WAngleLabel.ForeColor = Color.Gray;
WHeightTB.Enabled = false;
WPeriodTB.Enabled = false;
WAngleTB.Enabled = false;
WHeightTB.ReadOnly = true;
WPeriodTB.ReadOnly = true;
WAngleTB.ReadOnly = true;
WHeightTB.Text = "";
WPeriodTB.Text = "";
WAngleTB.Text = "";
}
else if (UA_WaveTick.Checked == false)
{
UA_WaveTick.Checked = false;
UALab.ForeColor = Color.Gray;
AsymLab.ForeColor = Color.Gray;
HighLab.ForeColor = Color.Gray;
AsymTB.Text = "";
HighTB.Text = "";
AsymTB.Enabled = false;
HighTB.Enabled = false;
AsymTB.ReadOnly = true;
HighTB.ReadOnly = true;
}
}
/*
private void WaveFileTick_CheckedChanged(object sender, EventArgs e)
{
if (WaveFileTick.Checked == true)
{
WaveBrowseButton.Enabled = true;
WaveFileTB.Enabled = true;
WaveFileTB.ReadOnly = false;
WaveBrowseButton.ForeColor = Color.Black;
WaveFileLabel.ForeColor = Color.Black;
WALoadLab.ForeColor = Color.Black;
WHLoadLab.ForeColor = Color.Black;
WPLoadLab.ForeColor = Color.Black;
BinnedLabel.ForeColor = Color.Black;
BinnedTick.Enabled = true;
ManWavTick.Checked = false;
}
else if (WaveFileTick.Checked == false)
{
WaveBrowseButton.Enabled = false;
WaveFileTB.Enabled = false;
WaveFileTB.ReadOnly = true;
WaveFileTB.Text = "";
WaveBrowseButton.ForeColor = Color.Gray;
WaveFileLabel.ForeColor = Color.Gray;
BinnedLabel.ForeColor = Color.Gray;
BinnedTick.Enabled = false;
WALoadLab.ForeColor = Color.Gray;
WHLoadLab.ForeColor = Color.Gray;
WPLoadLab.ForeColor = Color.Gray;
WALoadTB.Text = "";
WHLoadTB.Text = "";
WPLoadTB.Text = "";
}
}
private void WaveBrowseButton_Click(object sender, EventArgs e)
{
OpenFileDialog WaveFileName = new OpenFileDialog();
WaveFileName.InitialDirectory = Directory.GetCurrentDirectory();
if (WaveFileName.ShowDialog() == DialogResult.OK)
{
WaveFileTB.Text = WaveFileName.SafeFileName;
Stream fileStream = WaveFileName.OpenFile();
StreamReader reader = new StreamReader(fileStream);
// Get 1st Wave Angle, Period, Height in file
realWave_Content = reader.ReadLine();
realWave_Content = realWave_Content.Replace("\r\n", " ");
realWave_Content = realWave_Content.Replace("\t", " ");
realWave_Content = Regex.Replace(realWave_Content, @"\s+", " ");
realWave_Content = realWave_Content.Trim();
realWave_Split = realWave_Content.Split(' ');
fileStream.Close();
WaveAngleIn = Convert.ToDouble(realWave_Split[0]);
WavePeriodIn = Convert.ToDouble(realWave_Split[1]);
WaveHeightIn = Convert.ToDouble(realWave_Split[2]);
WALoadTB.Text = Convert.ToString(WaveAngleIn);
WPLoadTB.Text = Convert.ToString(WavePeriodIn);
WHLoadTB.Text = Convert.ToString(WaveHeightIn);
}
}
private void ManWavTick_CheckedChanged(object sender, EventArgs e)
{
if (ManWavTick.Checked == true)
{
WHeightLabel.ForeColor = Color.Black;
WPeriodLabel.ForeColor = Color.Black;
WAngleLabel.ForeColor = Color.Black;
WHeightTB.Enabled = true;
WPeriodTB.Enabled = true;
WAngleTB.Enabled = true;
WaveFileTick.Checked = false;
BinnedTick.Checked = false;
}
else if (ManWavTick.Checked == false)
{
WHeightLabel.ForeColor = Color.Gray;
WPeriodLabel.ForeColor = Color.Gray;
WAngleLabel.ForeColor = Color.Gray;
WHeightTB.Enabled = false;
WPeriodTB.Enabled = false;
WAngleTB.Enabled = false;
WHeightTB.Text = "";
WPeriodTB.Text = "";
WAngleTB.Text = "";
}
}
private void UA_WaveTickTick_CheckedChanged(object sender, EventArgs e)
{
if (UA_WaveTick.Checked == true)
{
WaveIn = 0;
}
}
*/
// Tides
private void DoTidesTick_CheckedChanged(object sender, EventArgs e)
{
if (DoTidesTick.Checked == true)
{
LowTideLab.ForeColor = Color.Black;
LowTideTB.Enabled = true;
LowTideTB.ReadOnly = false;
HighTideLab.ForeColor = Color.Black;
HighTideTB.Enabled = true;
HighTideTB.ReadOnly = false;
}
else if (DoTidesTick.Checked == false)
{
LowTideLab.ForeColor = Color.Gray;
LowTideTB.Enabled = false;
LowTideTB.ReadOnly = true;
LowTideTB.Text = "";
HighTideLab.ForeColor = Color.Gray;
HighTideTB.Enabled = false;
HighTideTB.ReadOnly = true;
HighTideTB.Text = "";
}
}
// SLR
private void DoSLRTick_CheckedChanged(object sender, EventArgs e)
{
if (DoSLRTick.Checked == true)
{
SLRLab.ForeColor = Color.Black;
SLR_TB.Enabled = true;
SLR_TB.ReadOnly = false;
RateSLRLab.ForeColor = Color.Black;
RateSLR_TB.Enabled = true;
RateSLR_TB.ReadOnly = false;
StepSLR_Lab.ForeColor = Color.Black;
StepSLR_Tick.Enabled = true;
}
else if (DoTidesTick.Checked == false)
{
SLRLab.ForeColor = Color.Gray;
SLR_TB.Enabled = false;
SLR_TB.ReadOnly = true;
SLR_TB.Text = "";
RateSLRLab.ForeColor = Color.Gray;
RateSLR_TB.Enabled = false;
RateSLR_TB.ReadOnly = true;
RateSLR_TB.Text = "";
StepSLR_Lab.ForeColor = Color.Gray;
StepSLR_Tick.Checked = false;
StepSLR_Tick.Enabled = false;
}
}
// Sources&Sinks
private void SourceTick_CheckedChanged(object sender, EventArgs e)
{
if (SourceTick.Checked == true)
{
NumSourceLab.ForeColor = Color.Black;
NumSourceTB.Enabled = true;
NumSourceTB.ReadOnly = false;
ColSourceTick.Checked = false;
ColSourceLab.ForeColor = Color.Black;
ColSourceTick.Enabled = true;
XSourceLab.ForeColor = Color.Black;
XSourceTB.Enabled = true;
XSourceTB.ReadOnly = false;
YSourceLab.ForeColor = Color.Black;
YSourceTB.Enabled = true;
YSourceTB.ReadOnly = false;
}
else if (SourceTick.Checked == false)
{
NumSourceLab.ForeColor = Color.Gray;
NumSourceTB.Enabled = false;
NumSourceTB.ReadOnly = true;
NumSourceTB.Text = "";
ColSourceLab.ForeColor = Color.Gray;
ColSourceTick.Enabled = false;
XSourceLab.ForeColor = Color.Gray;
XSourceTB.Enabled = false;
XSourceTB.ReadOnly = true;
XSourceTB.Text = "";
YSourceLab.ForeColor = Color.Gray;
YSourceTB.Enabled = false;
YSourceTB.ReadOnly = true;
YSourceTB.Text = "";
}
}
private void SinkTick_CheckedChanged(object sender, EventArgs e)
{
if (SinkTick.Checked == true)
{
NumSinkLab.ForeColor = Color.Black;
NumSinkTB.Enabled = true;
NumSinkTB.ReadOnly = false;
ColSinkTick.Checked = false;
ColSinkLab.ForeColor = Color.Black;
ColSinkTick.Enabled = true;
XSinkLab.ForeColor = Color.Black;
XSinkTB.Enabled = true;
XSinkTB.ReadOnly = false;
YSinkLab.ForeColor = Color.Black;
YSinkTB.Enabled = true;
YSinkTB.ReadOnly = false;
SinkinessLab.ForeColor = Color.Black;
SinkinessTB.Enabled = true;
SinkinessTB.ReadOnly = false;
}
else if (SinkTick.Checked == false)
{
NumSinkLab.ForeColor = Color.Gray;
NumSinkTB.Enabled = false;
NumSinkTB.ReadOnly = true;
NumSinkTB.Text = "";
ColSinkLab.ForeColor = Color.Gray;
ColSinkTick.Enabled = false;
XSinkLab.ForeColor = Color.Gray;
XSinkTB.Enabled = false;
XSinkTB.ReadOnly = true;
XSinkTB.Text = "";
YSinkLab.ForeColor = Color.Gray;
YSinkTB.Enabled = false;
YSinkTB.ReadOnly = true;
YSinkTB.Text = "";
SinkinessLab.ForeColor = Color.Gray;
SinkinessTB.Enabled = false;
SinkinessTB.ReadOnly = true;
SinkinessTB.Text = "";
}
}
private void ColSinkTick_CheckedChanged(object sender, EventArgs e)
{
if(ColSinkTick.Checked == true)
{
YSinkLab.ForeColor = Color.Gray;
YSinkTB.Text = "";
YSinkTB.Enabled = false;
YSinkTB.ReadOnly = true;
}
else if(ColSinkTick.Checked == false)
{
YSinkLab.ForeColor = Color.Black;
YSinkTB.Enabled = true;
YSinkTB.ReadOnly = false;
}
}
private void ColSourceTick_CheckedChanged(object sender, EventArgs e)
{
if (ColSourceTick.Checked == true)
{
YSourceLab.ForeColor = Color.Gray;
YSourceTB.Text = "";
YSourceTB.Enabled = false;
YSourceTB.ReadOnly = true;
}
else if (ColSourceTick.Checked == false)
{
YSourceLab.ForeColor = Color.Black;
YSourceTB.Enabled = true;
YSourceTB.ReadOnly = false;
}
}
private void toolTip1_Popup(object sender, PopupEventArgs e)
{
}
//Debug
private void SandOutputButton_Click(object sender, EventArgs e)
{
int x, y;
StreamWriter percentSandFile = new StreamWriter("TEST_FILES/percentSand" + counter + ".dat");
percentSandFile.Write(counter + Environment.NewLine);
for (y = ymax-1; y >= 0; y--)
{
for (x = 0; x < pbEnd; x++)
{
percentSandFile.Write(TElevationDomain[x, y] + " ");
}
percentSandFile.Write(Environment.NewLine);
}
percentSandFile.Close();
}
}
class point
{
//lat long variables
public double xcoord;
public double ycoord;
double transParallelX = 446.448;
double transParallelY = -125.157;
double transParallelZ = 542.060;
double scaleChange = -20.4894 * 0.000001;
double rotX = (0.1502 / 3600) * (Math.PI / 180);
double rotY = (0.2470 / 3600) * (Math.PI / 180);
double rotZ = (0.8421 / 3600) * (Math.PI / 180);
double a = 6377563.396; //airy 1830 semi-major axis
double b = 6356256.910; //airy 1830 semi-minor axis
double a2 = 6378137.000;
double b2 = 6356752.3142;
double eSquared = 0;
double eSquared2 = 0;
double nO = -100000;//northing of true origin
double eO = 400000;//easting of true origin
double fO = 0.9996012717;//scale factor
double latTrue = 49.0 * (Math.PI / 180.0);//latitude of true origin
double longTrue = -2.0 * (Math.PI / 180.0);//longitude of true origin
double psiHash, MBig, v, v2, v3, nLittle, rho, nSquare = 0;
double vii, viii, ix, Tx2, xi, xii, xiia = 0;
double helmertX, helmertY, helmertZ, cartX, cartY, cartZ;
double Height2 = 0;
double finalLati, finalLongi, latiRad, longiRad = 0;
double rootXYSqr = 0;
double PHI1, PHI2, PHI = 0;
public point(double theXcoord, double theYcoord)//constructor
{
this.xcoord = theXcoord;
this.ycoord = theYcoord;
}
public void transformPoint()//british os to lat long
{
eSquared = (Math.Pow(a, 2) - Math.Pow(b, 2)) / Math.Pow(a, 2);
Height2 = 0;
//OSGB36 easting and northing to OSGB36 latitude and longitude (lower left corner of DTM)
psiHash = ((this.ycoord - nO) / (a * fO)) + latTrue;
nLittle = (a - b) / (a + b);
MBig = b * fO * (((1 + nLittle + ((5.0 / 4.0) * Math.Pow(nLittle, 2)) + ((5.0 / 4.0) * Math.Pow(nLittle, 3))) * (psiHash -
latTrue))
- (((3.0 * nLittle) + (3.0 * Math.Pow(nLittle, 2)) + ((21.0 / 8.0) * Math.Pow(nLittle, 3))) *
Math.Sin(psiHash - latTrue) * Math.Cos(psiHash + latTrue))
+ (((15.0 / 8.0 * Math.Pow(nLittle, 2)) + (15.0 / 8.0 * Math.Pow(nLittle, 3))) * Math.Sin(2.0 * (psiHash - latTrue)) * Math.Cos(2.0 * (psiHash + latTrue)))
- ((35.0 / 24.0 * Math.Pow(nLittle, 3)) * Math.Sin(3.0 * (psiHash - latTrue)) * Math.Cos(3.0 * (psiHash + latTrue))));
if (Math.Abs((this.ycoord - nO - MBig)) >= 0.01)
{
while (Math.Abs((this.ycoord - nO - MBig)) >= 0.01)
{
psiHash = ((this.ycoord - nO - MBig) / (a * fO)) + psiHash;
MBig = b * fO * (((1 + nLittle + ((5.0 / 4.0) * Math.Pow(nLittle, 2)) + ((5.0 / 4.0) * Math.Pow(nLittle, 3))) * (psiHash -
latTrue))
- (((3.0 * nLittle) + (3.0 * Math.Pow(nLittle, 2)) + ((21.0 / 8.0) * Math.Pow(nLittle, 3))) *
Math.Sin(psiHash - latTrue) * Math.Cos(psiHash + latTrue))
+ (((15.0 / 8.0 * Math.Pow(nLittle, 2)) + (15.0 / 8.0 * Math.Pow(nLittle, 3))) * Math.Sin(2.0 * (psiHash - latTrue)) * Math.Cos(2.0 * (psiHash + latTrue)))
- ((35.0 / 24.0 * Math.Pow(nLittle, 3)) * Math.Sin(3.0 * (psiHash - latTrue)) * Math.Cos(3.0 * (psiHash + latTrue))));
}
}
v = a * fO * Math.Pow(1 - eSquared * Math.Pow(Math.Sin(psiHash), 2), -.5);
rho = a * fO * (1 - eSquared) * Math.Pow(1.0 - eSquared * Math.Pow(Math.Sin(psiHash), 2), -1.5);
nSquare = v / rho - 1.0;
vii = (Math.Tan(psiHash)) / (2.0 * rho * v);
viii = ((Math.Tan(psiHash)) / (24.0 * rho * Math.Pow(v, 3))) * (5 + 3.0 * Math.Pow(Math.Tan(psiHash), 2) + nSquare - 9.0 * (Math.Pow(Math.Tan(psiHash), 2) * nSquare));
ix = (Math.Tan(psiHash) / ((720.0 * rho * Math.Pow(v, 5)))) * (61 + 90.0 * Math.Pow(Math.Tan(psiHash), 2) + 45.0 * Math.Pow(Math.Tan(psiHash), 4));
Tx2 = (1.0 / Math.Cos(psiHash)) / v;
xi = (1.0 / Math.Cos(psiHash)) / (6.0 * Math.Pow(v, 3)) * ((v / rho) + (2.0 * Math.Pow(Math.Tan(psiHash), 2)));
xii = (1.0 / Math.Cos(psiHash)) / (120.0 * Math.Pow(v, 5)) * (5.0 + (28.0 * Math.Pow(Math.Tan(psiHash), 2)) + (24.0 * Math.Pow(Math.Tan(psiHash), 4)));
xiia = ((1.0 / Math.Cos(psiHash)) / (5040.0 * Math.Pow(v, 7))) * (61.0 + (662.0 * Math.Pow(Math.Tan(psiHash), 2)) + (1320.0 * Math.Pow(Math.Tan(psiHash), 4)) + (720.0 * Math.Pow(Math.Tan(psiHash), 6)));
latiRad = psiHash - (vii * Math.Pow((this.xcoord - eO), 2)) + (viii * Math.Pow((this.xcoord - eO), 4)) - (ix * Math.Pow((this.xcoord - eO), 6));
longiRad = longTrue + (Tx2 * (this.xcoord - eO)) - (xi * (Math.Pow((this.xcoord - eO), 3))) + (xii * (Math.Pow((this.xcoord - eO), 5))) - (xiia * (Math.Pow((this.xcoord - eO), 7)));
v2 = a / (Math.Sqrt(1 - (eSquared * ((Math.Pow(Math.Sin(latiRad), 2))))));
cartX = (v2 + Height2) * Math.Cos(latiRad) * Math.Cos(longiRad);
cartY = (v2 + Height2) * (Math.Cos(latiRad) * Math.Sin(longiRad));
cartZ = ((v2 * (1 - eSquared)) + Height2) * Math.Sin(latiRad);
helmertX = cartX + (cartX * scaleChange) - (cartY * rotZ) + (cartZ * rotY) + transParallelX;
helmertY = (cartX * rotZ) + cartY + (cartY * scaleChange) - (cartZ * rotX) + transParallelY;
helmertZ = (-1 * cartX * rotY) + (cartY * rotX) + cartZ + (cartZ * scaleChange) + transParallelZ;
rootXYSqr = Math.Sqrt((Math.Pow(helmertX, 2)) + (Math.Pow(helmertY, 2)));
eSquared2 = (Math.Pow(a2, 2) - Math.Pow(b2, 2)) / Math.Pow(a2, 2);
PHI1 = Math.Atan(helmertZ / (rootXYSqr * (1 - eSquared2)));
v3 = a2 / (Math.Sqrt(1.0 - (eSquared2 * ((Math.Pow(Math.Sin(PHI1), 2))))));
PHI2 = Math.Atan((helmertZ + (eSquared2 * v3 * (Math.Sin(PHI1)))) / rootXYSqr);
while (Math.Abs(PHI1 - PHI2) > 0.000000001)
{
PHI1 = PHI2;
v3 = a2 / (Math.Sqrt(1 - (eSquared2 * ((Math.Pow(Math.Sin(PHI1), 2))))));
PHI2 = Math.Atan((helmertZ + (eSquared2 * v3 * (Math.Sin(PHI1)))) / rootXYSqr);
}
PHI = PHI2;
finalLati = PHI * (180.0 / Math.PI);
finalLongi = (Math.Atan(helmertY / helmertX)) * (180.0 / Math.PI);
this.xcoord = finalLongi;
this.ycoord = finalLati;
}
}
}