Skip to content

Commit 1eb2e11

Browse files
authored
Merge pull request #32 from dvalters/Reach
Reach Mode
2 parents 3269667 + 732f8e8 commit 1eb2e11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2834799
-49
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ TARGET := bin/HAIL-CAESAR.exe
88
SRCEXT := cpp
99
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
1010
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
11-
CFLAGS := -g -std=c++11 -DOMP_COMPILE_FOR_PARALLEL -fopenmp $(GITREV)# -Wall
11+
CFLAGS := -g -std=c++11 -Wall -DDEBUG #-DOMP_COMPILE_FOR_PARALLEL -fopenmp $(GITREV)# -Wall
1212
LIB := -fopenmp
1313
INC := -I include
1414

@@ -24,7 +24,7 @@ $(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
2424

2525
clean:
2626
@echo " Cleaning...";
27-
@echo " $(RM) -r $(BUILDDIR)/catchmentmodel/ $(BUILDDIR)/topotools/ $(TARGET)"; $(RM) -r $(BUILDDIR)/catchmentmodel/ $(BUILDDIR)/topotools/ $(TARGET)
27+
@echo " $(RM) -r $(BUILDDIR)/main.o $(BUILDDIR)/catchmentmodel/ $(BUILDDIR)/topotools/ $(TARGET)"; $(RM) -r $(BUILDDIR)/main.o $(BUILDDIR)/catchmentmodel/ $(BUILDDIR)/topotools/ $(TARGET)
2828

2929
# Tests
3030
tester:
@@ -34,4 +34,4 @@ tester:
3434
ticket:
3535
$(CXX) $(CFLAGS) spikes/ticket.cpp $(INC) $(LIB) -o bin/ticket
3636

37-
.PHONY: clean
37+
.PHONY: clean

include/catchmentmodel/LSDCatchmentModel.hpp

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ class LSDCatchmentModel: public LSDRaster
135135
/// @details Actually, this is a generic function for printing a 2D vector
136136
void print_rainfall_data();
137137

138+
void print_reach_data();
139+
138140
/// @brief Calls the various save functions depending on the data types to be saved (Raster Output)
139141
/// @author DAV
140142
/// @details dependent on the LSDRaster class calling the overloaded write_raster func. If you are looking
@@ -337,6 +339,11 @@ class LSDCatchmentModel: public LSDRaster
337339
/// object.
338340
void catchment_water_input_and_hydrology( double flow_timestep, runoffGrid& runoff);
339341

342+
/// @brief Calculates the hydrological inputs using just reach mode
343+
void reach_water_and_sediment_input();
344+
345+
std::vector<std::vector<float> > read_reachfile(std::string REACHINPUTFILE);
346+
340347
/// @brief Gets the number of catchment cells that have water input to them
341348
/// @detail Calculates which cells contain a discharge greater than MIN_Q
342349
/// and lower than MIN_Q_MAXVAL multiplies by a parameter related to the
@@ -428,7 +435,8 @@ class LSDCatchmentModel: public LSDRaster
428435
const std::array<int, 9> deltaY = {{0, -1, -1, 0, 1, 1, 1, 0, -1}};
429436

430437
double water_depth_erosion_threshold = 0.01;
431-
int input_time_step = 60;
438+
int reach_input_data_timestep = 60;
439+
int stage_reach_input_data_timestep = 60;
432440
int number_of_points = 0;
433441
double globalsediq = 0;
434442
double time_1 = 1;
@@ -462,9 +470,11 @@ class LSDCatchmentModel: public LSDRaster
462470
unsigned rfnum = 1;
463471

464472
/// set by ncols and nrows
465-
unsigned int jmax, imax;
466-
double xll, yll;
467-
double no_data_value;
473+
unsigned int jmax = 0;
474+
unsigned int imax = 0;
475+
double xll = 0;
476+
double yll = 0;
477+
double no_data_value = -9999.9;
468478

469479
int maxcycle = 1000;
470480

@@ -478,7 +488,7 @@ class LSDCatchmentModel: public LSDRaster
478488
double CREEP_RATE=0.0025;
479489
double SOIL_RATE = 0.0025;
480490
double active=0.2;
481-
int grain_array_tot =1 ;
491+
int grain_array_tot =1;
482492

483493
/// Number of passes for edge smoothing filter
484494
double edge_smoothing_passes = 100.0;
@@ -598,8 +608,34 @@ class LSDCatchmentModel: public LSDRaster
598608
TNT::Array2D<int> down_scan;
599609
TNT::Array2D<int> rfarea;
600610

611+
// Reach input cell flag switches
612+
bool reach1_input_on = false;
613+
bool reach2_input_on = false;
614+
bool reach3_input_on = false;
615+
616+
std::string reach1_input_file;
617+
std::string reach2_input_file;
618+
std::string reach3_input_file;
619+
620+
int reach1_x;
621+
int reach1_y;
622+
int reach2_x;
623+
int reach2_y;
624+
int reach3_x;
625+
int reach3_y;
626+
627+
// Arrays for reach mode input points
628+
TNT::Array2D<int> inpoints;
601629
TNT::Array2D<bool> inputpointsarray;
602630

631+
std::vector< std::vector<float> > hourly_rain_data;
632+
std::vector<std::vector<std::vector<float> > > inputfile;
633+
//TNT::Array3D<double> inputfile;
634+
std::vector<double> stage_inputfile;
635+
// TODO above these all need initialising from read ins.
636+
637+
double stage_input_time_step = 1;
638+
603639
std::vector<int> catchment_input_x_coord;
604640
std::vector<int> catchment_input_y_coord;
605641

@@ -608,7 +644,7 @@ class LSDCatchmentModel: public LSDRaster
608644

609645
std::vector<double> hourly_m_value;
610646
std::vector<double> temp_grain;
611-
std::vector< std::vector<float> > hourly_rain_data;
647+
612648
TNT::Array3D<double> veg;
613649
TNT::Array2D<double> edge, edge2; //TJC 27/1/05 array for edges
614650
std::vector<double> old_j_mean_store;
@@ -681,21 +717,21 @@ class LSDCatchmentModel: public LSDRaster
681717
bool write_elevdiff_file = false;
682718

683719
/// input file names
684-
std::string rainfall_data_file;
685-
std::string grain_data_file;
686-
std::string bedrock_data_file;
720+
std::string rainfall_data_file = "";
721+
std::string grain_data_file = "";
722+
std::string bedrock_data_file = "";
687723

688724
/// output file names
689-
std::string elev_fname;
690-
std::string grainsize_fname;
691-
std::string params_fname;
692-
std::string waterdepth_fname;
693-
std::string flowvel_fname;
694-
std::string hydroindex_fname;
695-
std::string timeseries_fname;
696-
std::string elevdiff_fname;
697-
std::string raingrid_fname;
698-
std::string runoffgrid_fname;
725+
std::string elev_fname = "";
726+
std::string grainsize_fname = "";
727+
std::string params_fname = "";
728+
std::string waterdepth_fname = "";
729+
std::string flowvel_fname = "";
730+
std::string hydroindex_fname = "";
731+
std::string timeseries_fname = "";
732+
std::string elevdiff_fname = "";
733+
std::string raingrid_fname = "";
734+
std::string runoffgrid_fname = "";
699735

700736
bool DEBUG_print_cycle_on = false;
701737
bool DEBUG_write_raingrid = false;

include/catchmentmodel/LSDUtils.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ namespace LSDUtils
4343
}
4444

4545
// Wee function to check if file exists
46-
// Not sure if this works in Windows...must test sometime
4746
inline bool does_file_exist(const std::string &filename)
4847
{
4948
struct stat buffer;
50-
return (stat(filename.c_str(), &buffer) ==0);
49+
return (stat(filename.c_str(), &buffer) == 0);
5150
}
5251

5352
// A simple function to test OpenMP in the LSDTopoTools environment

0 commit comments

Comments
 (0)